Commit Graph

1421 Commits

Author SHA1 Message Date
David Ansari 3432dcb161 Shard shared_SUITE
such that MQTT and WebMQTT tests of the shared_SUITE can run in parallel.
Before this commit, the shared_SUITE runs 14 minutes, after this commit
the shared_SUITE runs 4 minutes in GitHub actions.
2023-02-07 16:36:08 +01:00
David Ansari 146570df5e Delete AMQP 0.9.1 header x-mqtt-dup
AMQP 0.9.1 header x-mqtt-dup was determined by the incoming MQTT PUBLISH
packet's DUP flag. Its only use was to determine the outgoing MQTT
PUBLISH packet's DUP flag. However, that's wrong behaviour because
the MQTT 3.1.1 protocol spec mandates:
"The value of the DUP flag from an incoming PUBLISH packet is not
propagated when the PUBLISH Packet is sent to subscribers by the Server.
The DUP flag in the outgoing PUBLISH packet is set independently to the
incoming PUBLISH packet, its value MUST be determined solely by whether
the outgoing PUBLISH packet is a retransmission."
[MQTT-3.3.1-3]

Native MQTT fixes this wrong behaviour. Therefore, we can delete this
AMQP 0.9.1 header.
2023-02-07 16:36:08 +01:00
David Ansari 5f6a1f96ca Remove unused NodeId parameter 2023-02-07 16:36:08 +01:00
David Ansari bec8f9a21c Support topic variable expansion for vhost and username
Native MQTT introduced a regression where the "{username}" and "{vhost}"
variables were not expanded in permission patterns.

This regression was unnoticed because the java_SUITE's
topicAuthorisationVariableExpansion test was wrongfully passing because
its topic started with "test-topic" which matched another allow listed
topic (namely "test-topic") instead of the pattern
"{username}.{client_id}.a".
This other java_SUITE regression got introduced by commit
26a17e8530

This commit fixes both the buggy Java test and the actual regression
introduced in Native MQTT.
2023-02-07 16:36:08 +01:00
David Ansari 1ba4823495 Delete unused files 2023-02-07 16:36:08 +01:00
David Ansari 804777f575 Explicitly match `maybe` return values 2023-02-07 16:36:08 +01:00
David Ansari 79c12b60bc Use maybe expression instead of messy patterns
This commit is pure refactoring making the code base more maintainable.

Replace rabbit_misc:pipeline/3 with the new OTP 25 experimental maybe
expression because
"Frequent ways in which people work with sequences of failable
operations include folds over lists of functions, and abusing list
comprehensions. Both patterns have heavy weaknesses that makes them less
than ideal."
https://www.erlang.org/eeps/eep-0049#obsoleting-messy-patterns

Additionally, this commit is more restrictive in the type spec of
rabbit_mqtt_processor state fields.
Specifically, many fields were defined to be `undefined | T` where
`undefined` was only temporarily until the first CONNECT packet was
processed by the processor.
It's better to initialise the MQTT processor upon first CONNECT packet
because there is no point in having a processor without having received
any packet.
This allows many type specs in the processor to change from `undefined |
T` to just `T`.
Additionally, memory is saved by removing the `received_connect_packet`
field from the `rabbit_mqtt_reader` and `rabbit_web_mqtt_handler`.
2023-02-07 16:36:08 +01:00
David Ansari 67a428a913 Add API functions to behaviour module
Include API functions to the rabbit_mqtt_retained_msg_store
behaviour module.

"There is a best practice to have the behaviour module include
the API also as it helps other parts of the code to be correct
and a bit more dialyzable."

This commit also fixes a bug where the retainer process had only
60 milliseconds shutdown time before being unconditionally killed.
60 milliseconds can be too short to dump a large ETS table containing
many retained messages to disk.
2023-02-07 15:42:16 +01:00
David Ansari 2d0826c335 Add OAuth 2.0 MQTT system test
Add a test that rabbitmq_auth_backend_oauth2 works with MQTT.

See https://github.com/rabbitmq/rabbitmq-oauth2-tutorial#mqtt-protocol
2023-02-03 14:08:51 +00:00
David Ansari 0706cad7a1 Fix pid tracking when decommissioning an MQTT node
Prior to this commit test `deps.rabbitmq_mqtt.cluster_SUITE`
`connection_id_tracking_with_decommissioned_node` was flaky and sometimes
failed with
```
{cluster_SUITE,connection_id_tracking_with_decommissioned_node,160}
{test_case_failed,failed to match connection count 0}
```
2023-02-02 19:33:29 +00:00
Jean-Sébastien Pédron 9a99480bc9
Merge pull request #6821 from rabbitmq/rabbit-db-modules
Move missing Mnesia-specific code to rabbit_db_* modules
2023-02-02 15:40:11 +01:00
Diana Parra Corbacho 9cf10ed8a7 Unit test rabbit_db_* modules, spec and API updates 2023-02-02 15:01:42 +01:00
Chunyi Lyu 6205e5e5e3 MQTT print stacktrace/payload only at debug level 2023-01-31 10:36:08 +00:00
David Ansari cbb389bb2a Remove MQTT processor field peer_addr
as it seems to always match peer_host.

Commit 7e09b85426 adds peer address
provided by WebMQTT plugin.

However, this seems unnecessary since function rabbit_net:peername/1 on
the unwrapped socket provides the same address.

The peer address was the address of the proxy if the proxy protocol is
enabled.

This commit simplifies code and reduces memory consumption.
2023-01-30 12:17:19 +00:00
David Ansari 02cf072ae4 Restrict MQTT CONNECT packet size
In MQTT 3.1.1, the CONNECT packet consists of
1. 10 bytes variable header
2. ClientId (up to 23 bytes must be supported)
3. Will Topic
4. Will Message (maximum length 2^16 bytes)
5. User Name
6. Password

Restricting the CONNECT packet size to 2^16 = 65,536 bytes
seems to be a reasonalbe default.

The value is configurable via the MQTT app parameter
`max_packet_size_unauthenticated`.

(Instead of being called `max_packet_size_connect`) the
name `max_packet_size_unauthenticated` is generic
because MQTT 5 introduces an AUTH packet type.
2023-01-29 15:00:19 +00:00
Chunyi Lyu 209f23fa2f
Revert "Format MQTT code with `erlfmt`" 2023-01-27 18:25:57 +00:00
Chunyi Lyu 1de9fcf582 Format mqtt files with erlfmt 2023-01-27 11:06:41 +00:00
Chunyi Lyu 50e25778bb Adding missing function specs 2023-01-25 19:34:24 +00:00
David Ansari 1f106fcd98 Fix wrong and add missing type specs 2023-01-25 17:13:54 +00:00
David Ansari ec137bc783 Add nested config record for rarely changing fields
When a single field in a record is updated, all remaining
fields' pointers are copied. Hence, if the record is large,
a lot will be copied.

Therefore, put static or rarely changing fields into their own record.

The same was done for the state in rabbit_channel or rabbit_fifo
for example.

Also, merge #info{} record into the new #cfg{} record.
2023-01-25 15:59:35 +00:00
David Ansari 9c2f5975ea Support tracing in Native MQTT 2023-01-24 17:32:59 +00:00
Chunyi Lyu 6cc65ecceb Export opaque types for event and mqtt_packet state 2023-01-24 17:32:59 +00:00
David Ansari 9db8626abf Re-enable dialyzer option Wunmatched_returns 2023-01-24 17:32:59 +00:00
David Ansari 8a2a82e19b Remove feature flag no_queue_name_in_classic_queue_client
as it was unnecessary to introduce it in the first place.

Remove the queue name from all queue type clients and pass the queue
name to the queue type callbacks that need it.

We have to leave feature flag classic_queue_type_delivery_support
required because we removed the monitor registry
1fd4a6d353/deps/rabbit/src/rabbit_queue_type.erl (L322-L325)

Implements review from Karl:
"rather than changing the message format we could amend the queue type
callbacks involved with the stateful operation to also take the queue
name record as an argument. This way we don't need to maintain the extra
queue name (which uses memory for known but obscurely technical reasons
with how maps work) in the queue type state (as it is used in the queue
type state map as the key)"
2023-01-24 17:32:59 +00:00
David Ansari cd8962b5fd Remove optional rabbit_queue_type callbacks
Instead of having optional rabbit_queue_type callbacks, add stub
implementations to rabbit_mqtt_qos0_queue throwing an exception.
The exception uses erlang:error/2 including stack trace and arguments
of the unsupported functions to ease debugging in case these functions
were ever to be called.

Dialyzer suppressions are added for these functions such that dialyzer
won't complain about:
```
rabbit_mqtt_qos0_queue.erl:244:1: Function init/1 only terminates with explicit exception
```
2023-01-24 17:32:59 +00:00
Chunyi Lyu d86ce70fd6 Add missing type definitions in mqtt records 2023-01-24 17:32:59 +00:00
David Ansari d4cfbddd35 Parse at most maximum packet length of 256MB
"This allows applications to send Control Packets of size up to
268,435,455 (256 MB)."
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718023
2023-01-24 17:32:59 +00:00
David Ansari 3f85f8d904 Do not log message payload
because it might contain large output.
2023-01-24 17:32:59 +00:00
David Ansari 437cbb73be Use delegate for stateless deliveries
For example when at-most-once dead lettering does a fan out to many
target classic queues this commit will reduce inter-node data traffic by
using delegate.
2023-01-24 17:32:59 +00:00
David Ansari 63ccf3ea3b Reduce inter-node traffic for MQTT QoS 0 queue type
Use delegate.

For large fan-outs with medium to large message size,
this commit will reduce inter-node data traffic by
multiple orders of magnitude preventing busy distribution
ports.
2023-01-24 17:32:59 +00:00
David Ansari a4db85de0d Make pipeline fail when there are dialyzer warnings
We want the build to fail if there are any dialyzer warnings in
rabbitmq_mqtt or rabbitmq_web_mqtt. Otherwise we rely on people manually
executing and checking the results of dialyzer.

Also, we want any test to fail that is flaky.
Flaky tests can indicate subtle errors in either test or program execution.
Instead of marking them as flaky, we should understand and - if possible -
fix the underlying root cause.

Fix OTP 25.0 dialyzer warning

Type gen_server:format_status() is known in OTP 25.2, but not in 25.0
2023-01-24 17:32:59 +00:00
David Ansari dcb00f1324 Reduce test load
Run test either on a RabbitMQ cluster of size 1 or size 3.
Running a test on both cluster sizes does not result in higher test
coverage.
This puts less pressure on Buildbuddy and reduces overall test
execution time.
2023-01-24 17:32:59 +00:00
David Ansari b5febb8a08 Hold subsriptions in process state
Although the first element (destination queue) of the compound key
in rabbit_reverse_route is provided, scaling tests with million of
subscribers have shown via timer:tc/1 that the mnesia:match_object/3
query often takes > 100 microseconds, sometimes even a few milliseconds.
So, querying bindings is not super expensive, but moderately expensive
when done many times concurrenlty.

Espcecially when mass diconnecting millions of clients, `msacc` showed
that all schedulers were 80% busy in `ets`.

To put less pressure on the CPU, in this commit we rather decide to
slightly increase memory usage.

When first connecting a client, we only query bindings and cache them in
the process state if a prior session for the same client is present.
Thereafter, bindings are not queried again.
2023-01-24 17:32:59 +00:00
David Ansari f46f0541ea Fix "Clean Session" state for QoS 0 subscriptions
Up to RabbitMQ 3.11, the following bug existed.

The MQTT 3.1.1. protocol spec mandates:
```
The Session state in the Server consists of:
* The Client’s subscriptions.
* ...
```

However, because QoS 0 queues were auto-delete up to 3.11 (or exclusive
prior to this commit), QoS 0 queues and therefore their bindings were
deleted when a non-clean session terminated.

When the same client re-connected, its QoS 0 subscription was lost.
Note that storing **messages** for QoS 0 subscription is optional while the
client is disconnected. However, storing the subscription itself (i.e.
bindings in RabbitMQ terms) is not optional: The client must receive new
messages for its QoS 0 subscriptions after it reconnects without having
to send a SUBSCRIBE packet again.

"After the disconnection of a Session that had CleanSession set to 0,
the Server MUST store further QoS 1 and QoS 2 messages that match any
subscriptions that the client had at the time of disconnection as part
of the Session state [MQTT-3.1.2-5]. It MAY also store QoS 0 messages
that meet the same criteria."
This commit additionally implements the last sentence.
2023-01-24 17:32:59 +00:00
David Ansari 863b7ea16a Include non-AMQP connections in connection count
Prior to this commit:
```
rabbitmqctl status
...
Totals

Connection count: 0
Queue count: 64308
Virtual host count: 1
...
```
only counted AMQP connections, but did not include MQTT or stream
connections.

Let's include the count of all connections in the output of
`rabbitmqctl status`.
2023-01-24 17:32:59 +00:00
David Ansari 35afeffceb Eliminate bindings query CPU bottleneck
Prior to this commit, there was a CPU bottleneck (not present in 3.11.x)
when creating, deleting or disconnecting many MQTT subscribers.

Example:
Add 120 MQTT connections per second each creating a subscription.
Starting at around 300k MQTT subscribers, all 45 CPUs on the server were
maxed out spending time in `ets` according to msacc.

When running a similar workload with only 30k MQTT subscribers on a
local server with only 5 CPUs, all 5 CPUs were maxed out and the CPU
flame graph showed that 86% of the CPU time is spent in function
rabbit_mqtt_processor:topic_names/2.

This commit uses the rabbit_reverse_route table to query MQTT
subscriptions for a given client ID. CPU usage is now drastically lower.

The configured source topic exchange is always the same in the MQTT
plugin. There is however a high cardinality in the destination queues
(MQTT client IDs) and routing keys (topics).
2023-01-24 17:32:59 +00:00
David Ansari a341912b75 Expand clean_session=false test 2023-01-24 17:32:59 +00:00
David Ansari 9283b4f4f6 Add test AMQP 0.9.1 to MQTT with QoS 0 2023-01-24 17:32:59 +00:00
David Ansari fb93a3c17d Block only publishing (Web) MQTT connections
When a cluster wide memory or disk alarm is fired, in AMQP 0.9.1 only
connections that are publishing messages get blocked.
Connections that only consume can continue to empty the queues.

Prior to this commit, all MQTT connections got blocked during a memory
or disk alarm. This has two downsides:
1. MQTT connections that only consume, but never published, cannot empty
   queues anymore.
2. If the memory or disk alarm takes long, the MQTT client does not
   receive a PINGRESP from the server when it sends a PINGREQ potentially
   leading to mass client disconnection (depending on the MQTT client
   implementation).

This commit makes sure that an MQTT connection that never sent a single
PUBLISH packet (e.g. "pure" MQTT subscribers) are not blocked during
memory or disk alarms.

In contrast to AMQP 0.9.1, new connections are still blocked from being
accepted because accepting (many) new MQTT connections also lead to
increased resource usage.

The implemenation as done in this commit is simpler, but also more naive
than the logic in rabbit_reader: rabbit_reader blocks connections more
dynamically whereas rabbit_mqtt_reader and rabbit_web_mqtt_handler
block a connection if the connection ever sent a single PUBLISH packet
during its lifetime.
2023-01-24 17:32:59 +00:00
David Ansari 6ba2dc4afc Switch to Logger macros
Convert from the old rabbit_log* API to the new Logger macros for MQTT
and Web MQTT connections.

Advantages:
* metadata mfa, file, line, pid, gl, time is auto-inserted by Logger.
* Log lines output by the shared module rabbit_mqtt_processor now
  include via the domain whether it's a MQTT or Web MQTT connection.

Instead of using domain [rabbitmq, connection], this commit now uses
the smaller and more specialized domains [rabbitmq, connection, mqtt] and
[rabbitmq, connection, web_mqtt] for MQTT and Web MQTT processes
respectively, resulting in the following example output:
"msg":"Received a CONNECT,", "domain":"rabbitmq.connection.mqtt"
or
"msg":"Received a CONNECT,", "domain":"rabbitmq.connection.web_mqtt"
2023-01-24 17:32:59 +00:00
David Ansari d651f87ea7 Share tests between MQTT and Web MQTT
New test suite deps/rabbitmq_mqtt/test/shared_SUITE contains tests that
are executed against both MQTT and Web MQTT.

This has two major advantages:
1. Eliminates test code duplication between rabbitmq_mqtt and
rabbitmq_web_mqtt making the tests easier to maintain and to understand.
2. Increases test coverage of Web MQTT.

It's acceptable to add a **test** dependency from rabbitmq_mqtt to
rabbitmq_web_mqtt. Obviously, there should be no such dependency
for non-test code.
2023-01-24 17:32:59 +00:00
David Ansari 7c1aa49361 Increase MQTT test coverage and fix edge cases 2023-01-24 17:32:59 +00:00
David Ansari c9df098f5c Handle topic, username, password as binaries
Topic, username, and password are parsed as binaries.
Storing topics as lists or converting between
lists and binaries back and forth several times is
unnecessary and expensive.
2023-01-24 17:32:59 +00:00
David Ansari fb6c8da2fc Block Web MQTT connection if memory or disk alarm
Previously (until RabbitMQ v3.11.x), a memory or disk alarm did
not block the Web MQTT connection because this feature was only
implemented half way through: The part that registers the Web MQTT
connection with rabbit_alarm was missing.
2023-01-24 17:32:59 +00:00
David Ansari a8b69b43c1 Fix dialyzer issues and add function specs
Fix all dialyzer warnings in rabbitmq_mqtt and rabbitmq_web_mqtt.

Add more function specs.
2023-01-24 17:32:58 +00:00
David Ansari 1720aa0e75 Allow CLI listing rabbit_mqtt_qos0_queue queues 2023-01-24 17:30:10 +00:00
David Ansari 56e97a9142 Fix MQTT in management plugin
1. Allow to inspect an (web) MQTT connection.
2. Show MQTT client ID on connection page as part of client_properties.
3. Handle force_event_refresh (when management_plugin gets enabled
   after (web) MQTT connections got created).
4. Reduce code duplication between protocol readers.
5. Display '?' instead of 'NaN' in UI for absent queue metrics.
6. Allow an (web) MQTT connection to be closed via management_plugin.

For 6. this commit takes the same approach as already done for the stream
plugin:
The stream plugin registers neither with {type, network} nor {type,
direct}.
We cannot use gen_server:call/3 anymore to close the connection
because the web MQTT connection cannot handle gen_server calls (only
casts).
Strictly speaking, this commit requires a feature flag to allow to force
closing stream connections from the management plugin during a rolling
update. However, given that this is rather an edge case, and there is a
workaround (connect to the node directly hosting the stream connection),
this commit will not introduce a new feature flag.
2023-01-24 17:30:10 +00:00
Chunyi Lyu cb68e4866e Resolve some dialyzer issues
- mqtt processor publish_to_queue/2 is called in
process_request(?PUBLISH,_, _) and maybe_send_will/3. In
both places #mqtt_msg{} is initialized with value so it will
never be 'undefined'.
- all possible value are already matched in mqtt_processor
human_readable_vhost_lookup_strategy/1; deleted the unneeded
catch all function clause.
- Removed a unnecessary case matching in mqtt_reader init/1.
Return values for 'rabbit_net:connection_string' are {ok, _} or
{error, _}. {'network_error', Reason} will never match.
- Fix function spec for mqtt_util gen_client_id/1. Return type of
rabbit_misc:base64url is string(), not binary().
2023-01-24 17:30:10 +00:00
Chunyi Lyu 4fa8e830ad Allow undefined in some mqtt record type fields
- to get rid of dialyzer warnings like "Record construction...
violates the declared type of field XYZ"
2023-01-24 17:30:10 +00:00
Chunyi Lyu 340e930d28 Web mqtt returns 1002 with mqtt parsing error
- it is a mqtt protocol error
2023-01-24 17:30:10 +00:00
Chunyi Lyu 4ca12b767a Fix func spec for mqtt process_request
- it also returns {stop, disconnect, state()} when receiving
a disconnect packet
- remove match for a {timeout, _} return when calling register_client.
register_client only returns {ok, _} and {error, _} according to its
function spec
2023-01-24 17:30:10 +00:00
Chunyi Lyu fb913009c4 Add func specs for mqtt process_packet and process_request
- removed return matching for {error, Error} when calling process_packet
because that's not the return type
2023-01-24 17:30:10 +00:00
David Ansari bd0acb33e4 Remove test helper util:connect_to_node/3
because this method is superfluous given that util:connect
already exists.
2023-01-24 17:30:10 +00:00
David Ansari 97fefff0fe Add overflow drop-head to rabbit_mqtt_qos_queue type
Traditionally, queue types implement flow control by keeping state in
both sending and receiving Erlang processes (for example credit based flow
control keeps the number of credits within the process dictionary).

The rabbit_mqtt_qos0_queue cannot keep such state in sending or receiving
Erlang process because such state would consume a large amount of memory
in case of large fan-ins or large fan-outs.
The whole idea of the rabbit_mqtt_qos_queue type is to not keep any
state in the rabbit_queue_type client. This makes this new queue
type scale so well.

Therefore the new queue type cannot (easily) implement flow control
throttling individual senders.

In this commit, we take a different approach:
Instead of implementing flow control throttling individual senders,
the receiving MQTT connection process drops QoS 0 messages from the
rabbit_mqtt_qos_queue if it is overflowed with messages AND its MQTT
client is not capable of receiving messages fast enough.

This is a simple and sufficient solution because it's better to drop QoS
0 (at most once) messages instead of causing cluster-wide memory alarms.

The user can opt out of dropping messages by setting the new env setting
mailbox_soft_limit to 0.

Additionally, we reduce the send_timeout from 30 seconds default in
Ranch to 15 seconds default in MQTT. This will detect hanging MQTT
clients faster causing the MQTT connection to be closed.
2023-01-24 17:30:10 +00:00
Chunyi Lyu de28560d8f Extract connect to node helper in rmq mqtt tests 2023-01-24 17:30:10 +00:00
Chunyi Lyu aea7ff8f8d Use helper to connect to node in mqtt cluster suite 2023-01-24 17:30:10 +00:00
David Ansari 61f6ca7b66 Support iodata() when sending message to MQTT client
When the MQTT connection receives an AMQP 0.9.1 message, it will contain
a list of payload fragments.

This commit avoids the expensive operation of turning that list into a binary.

All I/O methods accept iodata():
* erlang:port_command/2
* ssl:send/2
* In Web MQTT, cowboy websockets accept iodata():
0d04cfffa3/src/cow_ws.erl (L58)
2023-01-24 17:30:10 +00:00
David Ansari 15636fdb90 Rename frame to packet
The MQTT protocol specs define the term "MQTT Control Packet".
The MQTT specs never talk about "frame".

Let's reflect this naming in the source code since things get confusing
otherwise:
Packets belong to MQTT.
Frames belong to AMQP 0.9.1 or web sockets.
2023-01-24 17:30:10 +00:00
David Ansari 3980c28596 Allow higher load on Mnesia by default
Prior to this commit, when connecting or disconnecting many thousands of
MQTT subscribers, RabbitMQ printed many times:
```
[warning] <0.241.0> Mnesia('rabbit@mqtt-rabbit-1-server-0.mqtt-rabbit-1-nodes.default'): ** WARNING ** Mnesia is overloaded: {dump_log,write_threshold}
```

Each MQTT subscription causes queues and bindings to be written into Mnesia.

In order to allow for higher Mnesia load, the user can configure
```
[
 {mnesia,[
  {dump_log_write_threshold, 10000}
 ]}
].
```
in advanced.config

or set this value via
```
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-mnesia dump_log_write_threshold 10000"
```

The Mnesia default for dump_log_write_threshold is 1,000.
The Mnesia default for dump_log_time_threshold is 180,000 ms.

It is reasonable to increase the default for dump_log_write_threshold from
1,000 to 5,000 and in return decrease the default dump_log_time_threshold
from 3 minutes to 1.5 minutes.
This way, users can achieve higher MQTT scalability by default.

This setting cannot be changed at Mnesia runtime, it needs to be set
before Mnesia gets started.
Since the rabbitmq_mqtt plugin can be enabled dynamically after Mnesia
started, this setting must therefore apply globally to RabbitMQ.

Users can continue to set their own defaults via advanced.config or
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS. They continue to be respected
as shown by the new test suite included in this commit.
2023-01-24 17:30:10 +00:00
David Ansari 86de0a1557 Reduce memory usage of MQTT connection process
by removing the two fields referencing a function:
mqtt2amqp_fun and amqp2mqtt_fun

Each field required 1 words + 11 words for the function reference.

Therefore, for 1 million MQTT connections this commit saves:
    (1+11) * 2 * 1,000,000 words
    = 192 MB of memory

In addition, the code is now simpler to understand.

There is no change in behaviour except for the sparkplug environment
variable being read upon application start.

We put the compiled regexes into persistent term because they are the
same for all MQTT connections.
2023-01-24 17:30:10 +00:00
David Ansari 7782142020 Reduce memory usage of reader processes
Reduce memory usage of (Web) MQTT connection process and STOMP reader
process by storing the connection name as binary instead of string.

Previously:
82 = erts_debug:size("192.168.2.104:52497 -> 192.168.2.175:1883").

The binary <<"192.168.2.104:52497 -> 192.168.2.175:1883">>
requires 8 words.

So, for 1 million MQTT connections, this commit should save
    (82 - 8) words * 1,000,000
    = 592 MB
of memory.
2023-01-24 17:30:10 +00:00
Chunyi Lyu 46e8a65d96 Check if state.stats_timer is undefined to avoid crashing
- if #state.stats_timer is undefined, rabbit_event:if_enabled crashes
- remove compression related TODO from web_mqtt. It's a intentional
default behavior set in: https://github.com/rabbitmq/rabbitmq-web-mqtt/pull/35
2023-01-24 17:30:10 +00:00
David Ansari f842ffd250 Add feature flag rabbit_mqtt_qos0_queue
Routing to a queue of type rabbit_mqtt_qos0_queue hosted on
a remote node requires knowledge of that queue type on the
local node.
2023-01-24 17:30:10 +00:00
Chunyi Lyu 30a9ea521e Use connect helper func in more mqtt tests
- reduce code duplication
- connect helper does not unlink the connection process by default
2023-01-24 17:30:10 +00:00
David Ansari 1493cbe13d Rename message_id to packet_id
MQTT spec only talks about "Packet Identifier",
but never about "Message Identitier".

RabbitMQ has message identifiers (for example the classic queue store
uses message identifiers to uniquely identify internal messages).

So, let's not confuse these two terms and be specific.
2023-01-24 17:30:10 +00:00
David Ansari 7bc8208a1b Remove local record definitions from header files
Record #state{} is purely local to rabbit_mqtt_reader.
Record #proc_state{} is purely local to rabbit_mqtt_processor.

Therefore, move these record definitions to the defining module.
This avoids unnecessarily exposing internal information.

Now, that #proc_state{} is defined in rabbit_mqtt_processor,
rename #proc_state to #state{}.
2023-01-24 17:30:10 +00:00
David Ansari 6815ceb54a Fix mixed version reader_SUITE will test 2023-01-24 17:30:10 +00:00
David Ansari 76f4598d92 Send last will if client did not DISCONNECT
"The Will Message MUST be published when the Network Connection is subsequently
closed unless the Will Message has been deleted by the Server on receipt of a
DISCONNECT Packet [MQTT-3.1.2-8].
Situations in which the Will Message is published include, but are not limited to:
•	An I/O error or network failure detected by the Server.
•	The Client fails to communicate within the Keep Alive time.
•	The Client closes the Network Connection without first sending a DISCONNECT Packet.
•	The Server closes the Network Connection because of a protocol error.
"

Prior to this commit, the will message was not sent in all scenarios
where it should have been sent.

In this commit, the will message is always sent unless the client sent a
DISCONNECT packet to the server.

We achieve this by sending the will message in the terminate callback.

Note that the Reason passed into the terminate callback of
rabbit_web_mqtt_handler is the atom 'stop' (that is, we cannot pass a custom
reason here).

Therefore, in order to know within the terminate callback whether the client
sent a DISCONNECT packet, we have to modify the process state.
Rather than including a new field into the process state record which requires
1 additional word per MQTT connection (i.e. expensive with millions of
MQTT connection processes - we want to keep the process state small),
we intead modify the state just before stopping the process to
{SendWill, State}.
2023-01-24 17:30:10 +00:00
David Ansari 14b3b93b25 Make ff_SUITE less flaky 2023-01-24 17:30:10 +00:00
David Ansari 65bc0c395b Fix global counters
Prior to this commit messages_delivered for queue_type_qos0 is
wrongfully incremented if clean session is false

Also, delete duplicate code.
2023-01-24 17:30:10 +00:00
Chunyi Lyu 075bc06623 Handle messages_delivered_consume_*_ack counters at delivery
- increment messages_delivered_consume_auto_ack if subscribe queue
is type mqtt_qos0 queue or if publising QoS is 0
- increment messages_delivered_consume_manual_ack if both publising
and subcribe are QoS 1
- increment messages_acknowledged at queue_type:settle()
2023-01-24 17:30:10 +00:00
David Ansari 16fa12244e Avoid exceptions in mixed version cluster
1. Avoid following exceptions in mixed version clusters when new MQTT
   connections are created:
```
{{exception,{undef,[{rabbit_mqtt_util,remove_duplicate_clientid_connections,
                                      [{<<"/">>,
                                        <<"publish_to_all_queue_types">>},
                                       <0.1447.0>],
                                      []}]}},
 [{erpc,execute_cast,3,[{file,"erpc.erl"},{line,621}]}]}
```
If feature flag delete_ra_cluster_mqtt_node is disabled, let's still
populate pg with MQTT client IDs such that we don't have to migrate them
from the Ra cluster to pg when we enable the feature flag.
However, for actually closing duplicate MQTT client ID connections, if
that feature flag is disabled, let's rely on the Ra cluster to take care
of it.

2. Write a test ensuring the QoS responses are in the right order when a
   single SUBSCRIBE packet contains multiple subscriptions.
2023-01-24 17:30:10 +00:00
David Ansari 573934259a Consume from queue once
Each MQTT connection consumes from its queue at most once
(unless when failing over).
2023-01-24 17:30:10 +00:00
Chunyi Lyu c3779d9996 Implement message consuming counters in mqtt 2023-01-24 17:30:10 +00:00
David Ansari 6e527fb940 Replace existing subscription
"If a Server receives a SUBSCRIBE Packet containing a Topic Filter
that is identical to an existing Subscription’s Topic Filter then
it MUST completely replace that existing Subscription with a new
Subscription. The Topic Filter in the new Subscription will be
identical to that in the previous Subscription, although its
maximum QoS value could be different. Any existing retained
messages matching the Topic Filter MUST be re-sent, but the flow
of publications MUST NOT be interrupted [MQTT-3.8.4-3]."
2023-01-24 17:30:10 +00:00
David Ansari 0ba0a6e8f8 Several small improvements
1. The mqtt_qos0 queue type uses now QName in the delivery.
This makes the code simpler although it might be a bit less efficient
because the tuple containing binaries is sent around and a hash is
computed within rabbit_queue_type:module/2

2. Do not construct a new binary on every PUBACK. This is expensive with
   many PUBACKs per second. Instead, we store the QoS1 queue name in the
   process state (but only if the connection also consumes from that
   queue).

3. To make the code more readable, and less specialised, always handle
   queue actions when we call rabbit_queue_type:settle/5.
   This method only returns an action (delivery) when settling to the stream
   queue, which the MQTT plugin never does because an MQTT connection
   does not consume from a stream. It's not expensive at all to handle
   an empty list of queue actions.
2023-01-24 17:30:10 +00:00
David Ansari b2c87c59a0 Minor reformatting and renaming 2023-01-24 17:30:10 +00:00
David Ansari e06d3e7069 Unblock queue when it gets deleted
When a quorum queue or stream gets deleted while the MQTT connection
process (or channel) is blocked by that deleted queue due to soft limit
being exceeded, unblock that queue.

In this commit, an unblock action is also returned with the eol.
2023-01-24 17:30:09 +00:00
Chunyi Lyu 80f8e0754f Implement consumer global counter for clean sess false
- remove has_subs from proc state; query datebase to check
if a connection has subscription or not
2023-01-24 17:29:08 +00:00
David Ansari 016451ee87 Reset application env in MQTT flow tests
so that they run independently of other tests
2023-01-24 17:29:07 +00:00
Chunyi Lyu 0b43f002f5 Remove subscriptions map from proc state in mqtt
- subscriptions information can be retrieved directly from mnesia
- when unsubscribe, we check if there is binding between topic name
and queue (check for both qos0 queue name and qos1 queue name) to
unbind
- added a boolean value has_subs in proc state which will indicate
if connection has any active subscriptions. Used for setting consumer
global counter
2023-01-24 17:29:07 +00:00
David Ansari aad7e1cdf6 Add test for consuming MQTT classic queue going down 2023-01-24 17:29:07 +00:00
David Ansari bda52dbf64 Support consuming classic mirrored queue failover
Some users use classic mirrored queues for MQTT queues by
applying a policy.

Given that classic mirrored queues are deprecated, but still supported
in RabbitMQ 3.x, native MQTT must support classic mirrored queues.
2023-01-24 17:29:07 +00:00
David Ansari b97006c4b9 Output username in connection closed event 2023-01-24 17:29:07 +00:00
David Ansari 16b5ec5659 Add missing unblock stream queue action
Test flow control for all queue types.
2023-01-24 17:29:07 +00:00
David Ansari 7fc2234117 Test ETS and NOOP retained message stores 2023-01-24 17:29:07 +00:00
David Ansari 6533532039 Simplify counters
by storing mqtt310 and mqtt311 atoms directly in the processor state.
2023-01-24 17:29:07 +00:00
David Ansari ab5007a53b Handle queue deletion
Handle deletion of queues correctly that an MQTT connection is
publishing to with QoS 1.
2023-01-24 17:29:07 +00:00
Chunyi Lyu de984d026b Subs from 1 connection counts as 1 consumer in global counter
- rename proc state isPublisher to has_published
- create macro for v3 and v4 mqtt protocol name for global
counters
- sub groups in integration suite
2023-01-24 17:29:07 +00:00
David Ansari 38e5e20bb8 Add tests 2023-01-24 17:29:07 +00:00
Chunyi Lyu 17c5dffe7a Set common global counters for mqtt
- protocols are set to mqtt301 or mqtt311 depends
on protocal version set by client connection
- added boolean isPublisher in proc state to track
if connection was ever used to publish. This is used to
set publisher_create and publisher_delete global counters.
- tests added in integration_SUITE
2023-01-24 17:29:07 +00:00
David Ansari 9fd5704e30 Fix mixed version Web MQTT system tests
In mixed verion tests all non-required feature flags are disabled.
Therefore, MQTT client ID tracking happens in Ra.
The Ra client sends commands asynchronously when registering and
deregistering the client ID.

Also, add more tests.
2023-01-24 17:29:07 +00:00
Chunyi Lyu 96854a8c4c Use emqtt:publish in mqtt tests
- rename publish_qos1 to publish_qos1_timeout
since it's only been used for handling publisher timeout
more gracefully in tests
2023-01-24 17:29:07 +00:00
David Ansari 319af3872e Handle duplicate packet IDs
"If a Client re-sends a particular Control Packet, then it MUST use the
same Packet Identifier in subsequent re-sends of that packet."

A client can re-send a PUBLISH packet with the same packet ID.
If the MQTT connection process already received the original packet and
sent it to destination queues, it will ignore this re-send.

The packet ID will be acked to the publisher once a confirmation from
all target queues is received.

There should be no risk of "stuck" messages within the MQTT connection
process because quorum and stream queue clients re-send the message and
classic queues will send a monitor DOWN message in case they are down.
2023-01-24 17:29:07 +00:00
David Ansari 4c15299196 Delete old emqttc client
Instead use latest emqtt client for Web MQTT tests.
2023-01-24 17:29:07 +00:00
Chunyi Lyu 645531bc95 Register mqtt connections in case event refresh 2023-01-24 17:29:07 +00:00
David Ansari 14f59f1380 Handle soft limit exceeded as queue action
Instead of performing credit_flow within quorum queue and stream queue
clients, return new {block | unblock, QueueName} actions.

The queue client process can then decide what to do.

For example, the channel continues to use credit_flow such that the
channel gets blocked sending any more credits to rabbit_reader.

However, the MQTT connection process does not use credit_flow. It
instead blocks its reader directly.
2023-01-24 17:29:07 +00:00
David Ansari 816fedf080 Enable flow control to target classic queue 2023-01-24 17:29:07 +00:00
David Ansari 33bf2150a5 Add test for publishing via MQTT to different queue types 2023-01-24 17:29:07 +00:00
Chunyi Lyu 8126925617 Implement format_status for mqtt reader
- truncate queue type state from mqtt proc_state, which
could be huge with many destination queues. Instead, format_status
now returns number of destination queues.
2023-01-24 17:29:07 +00:00
David Ansari 627ea8588a Add rabbit_event tests for MQTT
Add tests that MQTT plugin sends correct events to rabbit_event.

Add event connection_closed.
2023-01-24 17:29:07 +00:00
Chunyi Lyu b74dea4435 Send rabbit event declaring mqtt_qos0 queue 2023-01-24 17:29:07 +00:00
David Ansari 07ad410d81 Skip queue when MQTT QoS 0
This commit allows for huge fanouts if the MQTT subscriber connects with
clean_session = true and QoS 0. Messages are not sent to a conventional queue.
Instead, messages are forwarded directly from MQTT publisher connection
process or channel to MQTT subscriber connection process.
So, the queue process is skipped.

The MQTT subscriber connection process acts as the queue process.
Its mailbox is a superset of the queue. This new queue type is called
rabbit_mqtt_qos0_queue.
Given that the only current use case is MQTT, this queue type is
currently defined in the MQTT plugin.
The rabbit app is not aware that this new queue type exists.

The new queue gets persisted as any other queue such that routing via
the topic exchange contineues to work as usual. This allows routing
across different protocols without any additional changes, e.g. huge
fanout from AMQP client (or management UI) to all MQTT devices.

The main benefit is that memory usage of the publishing process is kept at
0 MB once garbage collection kicked in (when hibernating the gen_server).
This is achieved by having this queue type's client not maintain any
state. Previously, without this new queue type, the publisher process
maintained state of 500MB to all the 1 million destination queues even
long after stopping sending messages to these queues.

Another big benefit is that no queue process need to be created.
Prior to this commit, with 1 million MQTT subscribers, 3 million Erlang
processes got created: 1 million MQTT connection processes, 1 million classic
queue processes, and 1 million classic queue supervisor processes.
After this commit, only the 1 million MQTT connection processes get
created. Hence, a few GBs of process memory will be saved.

Yet another big benefit is that because the new queue type's client
auto-settles the delivery when sending, the publishing process only
awaits confirmation from queues who potentially have at-least-once
consumers. So, the publishing process is not blocked on sending the
confirm back to the publisher if 1 message is let's say routed to 1
million MQTT QoS 0 subscribers while 1 copy is routed to an important
quorum queue or stream and while a single out of the million MQTT
connection processes is down.

Other benefits include:
* Lower publisher confirm latency
* Reduced inter-node network traffic

In a certain sense, this commit allows RabbitMQ to act as a high scale
and high throughput MQTT router (that obviously can lose messages at any
time given the QoS is 0).
For example, it allows use cases as using RabbitMQ to send messages cheaply
and quickly to 1 million devices that happen to be online at the given
time: e.g. send a notification to any online mobile device.
2023-01-24 17:29:07 +00:00
David Ansari af68fb4484 Decrease memory usage of queue_type state
Prior to this commit, 1 MQTT publisher publishing to 1 Million target
classic queues requires around 680 MB of process memory.

After this commit, it requires around 290 MB of process memory.

This commit requires feature flag classic_queue_type_delivery_support
and introduces a new one called no_queue_name_in_classic_queue_client.

Instead of storing the binary queue name 4 times, this commit now stores
it only 1 time.

The monitor_registry is removed since only classic queue clients monitor
their classic queue server processes.

The classic queue client does not store the queue name anymore. Instead
the queue name is included in messages handled by the classic queue
client.

Storing the queue name in the record ctx was unnecessary.

More potential future memory optimisations:
* When routing to destination queues, looking up the queue record,
  delivering to queue: Use streaming / batching instead of fetching all
  at once
* Only fetch ETS columns that are necessary instead of whole queue
  records
* Do not hold the same vhost binary in memory many times. Instead,
  maintain a mapping.
* Remove unnecessary tuple fields.
2023-01-24 17:29:07 +00:00
David Ansari 4b1c2c870b Emit cluster-wide MQTT connection infos
When listing MQTT connections with the CLI, whether feature flag
delete_ra_cluster_mqtt_node is enabled or disabled, in both cases
return cluster wide MQTT connections.

If connection tracking is done in Ra, the CLI target node returns all
connection infos because Ra is aware of all MQTT connections.

If connection tracking is done in (local-only) pg, all nodes return
their local MQTT connection infos.
2023-01-24 17:29:07 +00:00
David Ansari 3e28a52066 Convert rabbit_mqtt_reader from gen_server2 to gen_server
There is no need to use gen_server2.

gen_server2 requires lots of memory with millions of MQTT connections
because it creates 1 entry per connection into ETS table
'gen_server2_metrics'.

Instead of using handle_pre_hibernate, erasing the permission cache
is now done by using a timeout.

We do not need a hibernate backoff feature, simply hibernate after 1
second.

It's okay for MQTT connection processes to hibernate because they
usually send data rather rarely (compared to AMQP connections).
2023-01-24 17:29:07 +00:00
David Ansari 199238d76e Use pg to track MQTT client IDs
Instead of tracking {Vhost, ClientId} to ConnectionPid mappings in our
custom process registry, i.e. custom local ETS table with a custom
gen_server process managing that ETS table, this commit uses the pg module
because pg is better tested.

To save memory with millions of MQTT client connections, we want to save
the mappings only locally on the node where the connection resides and
therfore not be replicated across all nodes.

According to Maxim Fedorov:
"The easy way to provide per-node unique pg scope is to start it like
pg:start_link(node()). At least that's what we've been doing to have
node-local scopes. It will still try to discover scopes on nodeup from
nodes joining the cluster, but since you cannot have nodes with the
same name in one cluster, using node() for local-only scopes worked
well for us."

So that's what we're doing in this commit.
2023-01-24 17:29:07 +00:00
David Ansari ab8957ba9c Use best-effort client ID tracking
"Each Client connecting to the Server has a unique ClientId"

"If the ClientId represents a Client already connected to
the Server then the Server MUST disconnect the existing
Client [MQTT-3.1.4-2]."

Instead of tracking client IDs via Raft, we use local ETS tables in this
commit.

Previous tracking of client IDs via Raft:
(+) consistency (does the right thing)
(-) state of Ra process becomes large > 1GB with many (> 1 Million) MQTT clients
(-) Ra process becomes a bottleneck when many MQTT clients (e.g. 300k)
    disconnect at the same time because monitor (DOWN) Ra commands get
    written resulting in Ra machine timeout.
(-) if we need consistency, we ideally want a single source of truth,
    e.g. only Mnesia, or only Khepri (but not Mnesia + MQTT ra process)

While above downsides could be fixed (e.g. avoiding DOWN commands by
instead doing periodic cleanups of client ID entries using session interval
in MQTT 5 or using subscription_ttl parameter in current RabbitMQ MQTT config),
in this case we do not necessarily need the consistency guarantees Raft provides.

In this commit, we try to comply with [MQTT-3.1.4-2] on a best-effort
basis: If there are no network failures and no messages get lost,
existing clients with duplicate client IDs get disconnected.

In the presence of network failures / lost messages, two clients with
the same client ID can end up publishing or receiving from the same
queue. Arguably, that's acceptable and less worse than the scaling
issues we experience when we want stronger consistency.

Note that it is also the responsibility of the client to not connect
twice with the same client ID.

This commit also ensures that the client ID is a binary to save memory.

A new feature flag is introduced, which when enabled, deletes the Ra
cluster named 'mqtt_node'.

Independent of that feature flag, client IDs are tracked locally in ETS
tables.
If that feature flag is disabled, client IDs are additionally tracked in
Ra.

The feature flag is required such that clients can continue to connect
to all nodes except for the node being udpated in a rolling update.

This commit also fixes a bug where previously all MQTT connections were
cluster-wide closed when one RabbitMQ node was put into maintenance
mode.
2023-01-24 17:29:07 +00:00
David Ansari 43bd548dcc Handle deprecated classic queue delivery
when feature flag classic_queue_type_delivery_support is disabled.
2023-01-24 17:29:07 +00:00
David Ansari 5710a9474a Support MQTT Keepalive in WebMQTT
Share the same MQTT keepalive code between rabbit_mqtt_reader and
rabbit_web_mqtt_handler.

Add MQTT keepalive test in both plugins rabbitmq_mqtt and
rabbitmq_web_mqtt.
2023-01-24 17:29:07 +00:00
David Ansari 6f00ccb3ad Get all existing rabbitmq_web_mqtt tests green 2023-01-24 17:29:07 +00:00
David Ansari a02cbb73a1 Get all existing rabbitmq_mqtt tests green 2023-01-24 17:29:07 +00:00
David Ansari 23dac495ad Support QoS 1 for sending and receiving 2023-01-24 17:29:07 +00:00
David Ansari cdd253ee87 Receive many messages from classic queue
Before this commit, a consumer from a classic queue was receiving max
200 messages:
bb5d6263c9/deps/rabbit/src/rabbit_queue_consumers.erl (L24)

MQTT consumer process must give credit to classic queue process
due to internal flow control.
2023-01-24 17:29:07 +00:00
David Ansari 99337b84d3 Emit stats
'connection' field is not needed anymore because it was
previously the internal AMQP connection PID
2023-01-24 17:29:07 +00:00
David Ansari 218ee196c4 Make proxy_protocol tests green 2023-01-24 17:29:07 +00:00
David Ansari 77da78f478 Get most auth_SUITE tests green
Some tests which require clean_start=false
or QoS1 are skipped for now.

Differentiate between v3 and v4:
v4 allows for an error code in SUBACK frame.
2023-01-24 17:29:07 +00:00
David Ansari 73ad3bafe7 Revert maybe expression
rabbit_misc:pipeline looks better and doesn't require experimental
feature
2023-01-24 17:29:07 +00:00
David Ansari f4d1f68212 Move authn / authz into rabbitmq_mqtt 2023-01-24 17:29:07 +00:00
David Ansari eac0622f37 Consume with QoS0 via queue_type interface 2023-01-24 17:29:07 +00:00
David Ansari 24b0a6bcb2 Publish with QoS0 via queue_type interface 2023-01-24 17:29:07 +00:00
David Ansari 8710565b2a Use 1 instead of 22 Erlang processes per MQTT connection
* Create MQTT connections without proxying via AMQP
* Do authn / authz in rabbitmq_mqtt instead of rabbit_direct:connect/5
* Remove rabbit_heartbeat process and per connection supervisors

Current status:

Creating 10k MQTT connections with clean session succeeds:
./emqtt_bench conn -V 4 -C true -c 10000 -R 500
2023-01-24 17:29:07 +00:00
Michael Klishin 3bfba02281
Merge pull request #6919 from rabbitmq/rin/rework-elixir-dialyze
Rework elixir dialyze
2023-01-21 12:11:02 -06:00
Rin Kuryloski b84e746ee9 Rework plt/dialyze for rabbitmqctl and plugins that depend on it
This allows us to stop ignorning undefined callback warnings

When mix compiles rabbitmqctl, it produces a 'consolidated' directory
alongside the 'ebin' dir. Some of the modules in consolidated are
intended to be used instead of those provided by elixir. We now handle
the conflicts properly in the bazel build.
2023-01-19 17:29:23 +01:00
Alexey Lebedeff b6cd708a08 Fix all dialyzer warnings in rabbitmq_web_mqtt 2023-01-19 17:23:23 +01:00
Rin Kuryloski 5ef8923462 Avoid the need to pass package name to rabbitmq_integration_suite 2023-01-18 15:25:27 +01:00
Rin Kuryloski a317b30807 Use improved assert_suites2 macro from rules_erlang 3.9.0 2023-01-18 15:07:06 +01:00
Michael Klishin ec4f1dba7d
(c) year bump: 2022 => 2023 2023-01-01 23:17:36 -05:00
Jean-Sébastien Pédron 15d9cdea61
Call `rabbit:data_dir/0` instead of `rabbit_mnesia:dir/0`
This is a follow-up commit to the parent commit. To quote part of the
parent commit's message:

> Historically, this was the Mnesia directory. But semantically, this
> should be the reverse: RabbitMQ owns the data directory and Mnesia is
> configured to put its files there too.

Now all subsystems call `rabbit:data_dir/0`. They are not tied to Mnesia
anymore.
2022-11-30 14:41:32 +01:00
David Ansari 5bf8192982 Support code coverage
Previously it was not possible to see code coverage for the majority of
test cases: integration tests that create RabbitMQ nodes.
It was only possible to see code coverage for unit tests.
This commit allows to see code coverage for tests that create RabbitMQ
nodes.

The only thing you need to do is setting the `COVER` variable, for example
```
make -C deps/rabbitmq_mqtt ct COVER=1
```
will show you coverage across all tests in the MQTT plugin.

Whenever a RabbitMQ node is started `ct_cover:add_nodes/1` is called.
Contrary to the documentation which states

> To have effect, this function is to be called from init_per_suite/1 (see common_test) before any tests are performed.

I found that it also works in init_per_group/1 or even within the test cases themselves.

Whenever a RabbitMQ node is stopped or killed `ct_cover:remove_nodes/1`
is called to transfer results from the RabbitMQ node to the CT node.

Since the erlang.mk file writes a file called `test/ct.cover.spec`
including the line:
```
{export,".../rabbitmq-server/deps/rabbitmq_mqtt/cover/ct.coverdata"}.
```
results across all test suites will be accumulated in that file.

The accumulated result can be seen through the link `Coverage log` on the test suite result pages.
2022-11-10 15:04:31 +01:00
David Ansari 694501b923 Close local MQTT connections when draining node
When a node gets drained (i.e. goes into maintenance mode), only local
connections should be terminated.

However, prior to this commit, all MQTT connections got terminated
cluster-wide when a single node was drained.
2022-10-13 11:14:01 +00:00
Luke Bakken 7fe159edef
Yolo-replace format strings
Replaces `~s` and `~p` with their unicode-friendly counterparts.

```
git ls-files *.erl | xargs sed -i.ORIG -e s/~s>/~ts/g -e s/~p>/~tp/g
```
2022-10-10 10:32:03 +04:00
Michal Kuratczyk 2855278034
Migrate from supervisor2 to supervisor 2022-09-27 13:53:06 +02:00
David Ansari 307e6730cc Point emqtt test dependency from ansd to emqx
Given that https://github.com/emqx/emqtt/pull/169 has been merged
and a new tag has been set on emqx/emqtt,
we do not need the fork ansd/emqtt anymore.
2022-09-21 19:07:25 +02:00
Péter Gömöri c4b7cd98bf Add login_timeout to mqtt and stomp reader
Similarly to handshake_timeout in amqp reader.
2022-09-12 17:48:48 +02:00
David Ansari b953b0f10e Stop sending stats to rabbit_event
Stop sending connection_stats from protocol readers to rabbit_event.
Stop sending queue_stats from queues to rabbit_event.
Sending these stats every 5 seconds to the event manager process is
superfluous because noone handles these events.

They seem to be a relict from before rabbit_core_metrics ETS tables got
introduced in 2016.

Delete test head_message_timestamp_statistics because it tests that
head_message_timestamp is set correctly in queue_stats events
although queue_stats events are used nowhere.
The functionality of head_message_timestamp itself is still tested in
deps/rabbit/test/priority_queue_SUITE.erl and
deps/rabbit/test/temp/head_message_timestamp_tests.py
2022-09-09 10:52:38 +00:00
David Ansari 4c997f84bd Fix MQTT protocol version in MQTT tests
This is a follow-up commit of https://github.com/rabbitmq/rabbitmq-server/pull/5693

The allowed values of emqtt client library are:
```
{proto_ver, v3 | v4 | v5}
```

Therefore, `{proto_ver, 3}` did not have any effect and used the default
protocol version v4.

Let's fix the misleading version in our tests and be explicit that
we use v4.
2022-09-06 10:11:53 +02:00
David Ansari 1c96bf1315 Point emqtt test dependency to a tree reference
Since I force pushed to master branch of
https://github.com/ansd/emqtt, the old commit does
not belong to any branch anymore.

While Bazel is happy, make complains:
```
make -C deps/rabbitmq_mqtt ct
 DEP    emqtt (f6d7ddd391890f4db5f77c775e83cf0ffe3d2d76)
fatal: reference is not a tree: f6d7ddd391890f4db5f77c775e83cf0ffe3d2d76
```
2022-09-02 14:03:26 +00:00
David Ansari ac2a5d3dd3 Upgrade MQTT Erlang client
The rabbitmq_mqtt tests used an outdated MQTT Erlang client.
It was a fork that has not been updated for > 4 years.
This commit upgrades the client to the latest version.
Therefore, we can delete our fork https://github.com/rabbitmq/emqttc.git
2022-08-31 14:12:23 +00:00
David Ansari 49ed70900e Fix failing proxy_protocol test
Prior to this commit, test
```
make -C deps/rabbitmq_web_mqtt ct-proxy_protocol t=http_tests:proxy_protocol
```

was failing with reason
```
exception error: no function clause matching
                 rabbit_net:sockname({rabbit_proxy_socket,#Port<0.96>,
```
2022-08-25 20:00:49 +02:00
David Ansari 28db862d56 Avoid crash when client disconnects before server handles MQTT CONNECT
In case of a resource alarm, the server accepts incoming TCP
connections, but does not read from the socket.
When a client connects during a resource alarm, the MQTT CONNECT frame
is therefore not processed.

While the resource alarm is ongoing, the client might time out waiting
on a CONNACK MQTT packet.

When the resource alarm clears on the server, the MQTT CONNECT frame
gets processed.

Prior to this commit, this results in the following crash on the server:
```
** Reason for termination ==
** {{badmatch,{error,einval}},
    [{rabbit_mqtt_processor,process_login,4,
                            [{file,"rabbit_mqtt_processor.erl"},{line,585}]},
     {rabbit_mqtt_processor,process_request,3,
                            [{file,"rabbit_mqtt_processor.erl"},{line,143}]},
     {rabbit_mqtt_processor,process_frame,2,
                            [{file,"rabbit_mqtt_processor.erl"},{line,69}]},
     {rabbit_mqtt_reader,process_received_bytes,2,
                         [{file,"src/rabbit_mqtt_reader.erl"},{line,307}]},
```

After this commit, the server just logs:
```
[error] <0.887.0> MQTT protocol error on connection 127.0.0.1:55725 -> 127.0.0.1:1883: peername_not_known
```

In case the client already disconnected, we want the server to bail out
early, i.e. not authenticating and registering the client at all
since that can be expensive when many clients connected while the
resource alarm was ongoing.

To detect whether the client disconnected, we rely on inet:peername/1
which will return an error when the peer is not connected anymore.

Ideally we could use some better mechanism for detecting whether the
client disconnected.

The MQTT reader does receive a {tcp_closed, Socket} message once the
socket becomes active. However, we don't really want to read frames
ahead (i.e. ahead of the received CONNECT frame), one reason being that:
"Clients are allowed to send further Control Packets immediately
after sending a CONNECT Packet; Clients need not wait for a CONNACK Packet
to arrive from the Server."

Setting socket option `show_econnreset` does not help either because the client
closes the connection normally.

Co-authored-by: Péter Gömöri @gomoripeti
2022-08-25 18:42:37 +02:00
Rin Kuryloski 165f946ffd Remove .travis.yml.patch files 2022-08-16 09:48:46 +02:00
Rin Kuryloski 575c5f9975 Remove all of the .travis.yml files
since we no longer use them
2022-08-16 09:46:31 +02:00
Jean-Sébastien Pédron 6e9ee4d0da
Remove test code which depended on the `quorum_queue` feature flags
These checks are now irrelevant as the feature flag is required.
2022-08-01 12:41:30 +02:00
Philip Kuryloski a250a533a4 Remove elixir related -ignore_xref calls
As they are no longer necessary with xref2 and the erlang.mk updates
2022-06-09 23:18:40 +02:00
Philip Kuryloski 15a79466b1 Use the new xref2 macro from rules_erlang
That adopts the modern erlang.mk xref behaviour
2022-06-09 23:18:28 +02:00
Philip Kuryloski 327f075d57 Make rabbitmq-server work with rules_erlang 3
Also rework elixir dependency handling, so we no longer rely on mix to
fetch the rabbitmq_cli deps

Also:

- Specify ra version with a commit rather than a branch
- Fixup compilation options for erlang 23
- Add missing ra reference in MODULE.bazel
- Add missing flag in oci.yaml
- Reduce bazel rbe jobs to try to save memory
- Use bazel built erlang for erlang git master tests
- Use the same cache for all the workflows but windows
- Avoid using `mix local.hex --force` in elixir rules
  - Fetching seems blocked in CI, and this should reduce hex api usage in
    all builds, which is always nice
- Remove xref and dialyze tags since rules_erlang 3 includes them in
  the defaults
2022-06-08 14:04:53 +02:00
Loïc Hoguin dc70cbf281
Update Erlang.mk and switch to new xref code 2022-05-31 13:51:12 +02:00
David Ansari 20677395cd Check queue and exchange existence with ets:member/2
This reduces memory usage and improves code readability.
2022-05-10 10:16:40 +00:00
Péter Gömöri 52cb5796a3 Remove leftover compiler option for get_stacktrace 2022-05-03 18:40:49 +02:00
Michael Klishin 7c47d0925a
Revert "Correct a double quote introduced in #4603"
This reverts commit 6a44e0e2ef.

That wiped a lot of files unintentionally
2022-04-20 16:05:56 +04:00
Michael Klishin 6a44e0e2ef
Correct a double quote introduced in #4603 2022-04-20 16:01:29 +04:00
Luke Bakken dba25f6462
Replace files with symlinks
This prevents duplicated and out-of-date instructions.
2022-04-15 06:04:29 -07:00
Philip Kuryloski 2dd9bde891 Bring over PROJECT_APP_EXTRA_KEYS values from make to bazel 2022-04-07 17:39:33 +02:00
Philip Kuryloski a22234f6eb Updates for rules_erlang 2.5.0
rabbitmq_cli uses some private rules_erlang apis that have changed in
the upcoming release

Additionally:
- Avoid including both standard and test versions of amqp_client in
integration test suites
- Eliminate most of the compilation order hints (explicit first_srcs)
in the bazel build
- Fix an include statement - in bazel, an app is not available to
itself as a library at compilation time
2022-04-07 14:54:37 +02:00
Michael Klishin 0ae3f19698
mqtt.queue_type => mqtt.durable_queue_type 2022-03-31 19:48:00 +04:00
Gabriele Santomaggio 2c49748c70
Add quorum queues support for MQTT
Enable the quorum queue for MQTT only if CleanSession is False.
QQs don't support auto-delete flag so in case Clean session is True
the queue will be a classic queue.

Add another group test non_parallel_tests_quorum.
For Mixed test the quorum_queue feature flag must be enabled.

Add log message
2022-03-30 08:49:17 -07:00
Michael Klishin c38a3d697d
Bump (c) year 2022-03-21 01:21:56 +04:00
Philip Kuryloski dabf053cf8 Additional dialyzer warning fixes
Currently loading of the rabbitmq_cli defined behaviors compiled with
Elixir does not work, so we ignore the callback definitions contained therein
2022-02-25 18:14:35 +01:00
Philip Kuryloski 226e00fcd2 Tighten up dialyzer usage
now that rules_erlang no longer cascades up dialyzer warnings from deps
2022-02-24 11:18:41 +01:00
Philip Kuryloski d8201726ae Ignore dialyzer warnings for most apps 2022-02-21 09:19:56 +01:00
Philip Kuryloski 2ec7ed8a41 Mark rabbitmq_mqtt:auth_SUITE as flaky 2022-02-02 16:06:35 +01:00
Philip Kuryloski efcd881658 Use rules_erlang v2
bazel-erlang has been renamed rules_erlang. v2 is a substantial
refactor that brings Windows support. While this alone isn't enough to
run all rabbitmq-server suites on windows, one can at least now start
the broker (bazel run broker) and run the tests that do not start a
background broker process
2022-01-18 13:43:46 +01:00
Michael Klishin f7d32d69f8 Introduce a new CLI tool (scope), rabbitmq-tanzu
For Tanzu (commercial) plugins to attach their commands to instead of
polluting rabbitmqctl.

Pair: @pjk25
(cherry picked from commit 6e0f2436fa)
2021-11-30 14:54:09 +00:00
Alexey Lebedeff e0723d5e66 Prevent crash logs when mqtt user is missing permissions
Fixes #2941

This adds proper exception handlers in the right places. And tests
ensure that it indeed provides nice neat logs without large
stacktraces for every amqp operation.

Unnecessary checking for subscribe permissions on topic was dropped,
as `queue.bind` does exactly the same check. Topic permissions tests
were also added, and they indeed confirm that there was no change in
behaviour.

Ideally the same explicit topic permission check should be dropped for
publishing, but it's more complicated - so for now there only a
detailed comment in the source code explaining it.

A few other things were also optimized away:
- Using amqp client to test for queue existence
- Creating queues/starting consumptions too eagerly, even if not yet
  requested by client
2021-11-12 18:03:05 +01:00
Michael Klishin 0f6a9dac27
Introduce rabbit_nodes:all/0 2021-09-20 22:24:25 +03:00
Philip Kuryloski 2b6296c4e2 Mark //deps/rabbitmq_mqtt:cluster_SUITE as flaky 2021-09-08 11:53:05 +02:00
Philip Kuryloski f95fc8aa0c Increase some suite timeouts in bazel 2021-07-23 09:43:05 +02:00
Michael Klishin 7de491fd82
Merge pull request #3187 from rabbitmq/less-chatty-mqtt
Change a log line from INFO to DEBUG
2021-07-12 19:07:29 +03:00
Philip Kuryloski 8f9de08de7 Also assert no missing suites for all other deps 2021-07-12 18:05:55 +02:00
Michal Kuratczyk 41922b96cf
Change a log line from INFO to DEBUG
This line is printed on every new MQTT connection which leads to very chatty logs when there is a lot of connections. Given that the way MQTT uses vhosts is generally static (once set up, always the same for all connections), I think this can be a debug message instead.
2021-07-12 16:50:25 +02:00
Philip Kuryloski 8c7e7e0656 Revert "Default all `rabbitmq_integration_suite` to flaky in bazel"
This reverts commit 70cb8147b2.
2021-06-23 20:53:14 +02:00
Philip Kuryloski 70cb8147b2 Default all `rabbitmq_integration_suite` to flaky in bazel
Most tests that can start rabbitmq nodes have some chance of
flaking. Rather than chase individual flakes for now, this commit
changes the default (though it can still be overriden, as is the case
for config_scheme_SUITE in many places, since I have yet to see that
particular suite flake).
2021-06-21 16:10:38 +02:00
Philip Kuryloski 55b3b6a370 Mark //deps/rabbitmq_mqtt:java_SUITE as flaky in bazel 2021-06-21 11:16:45 +02:00
Philip Kuryloski 30f9a95b9f Add dialyze for remaning tier-1 plugins 2021-06-01 10:19:10 +02:00
Philip Kuryloski 98e71c45d8 Perform xref checks on many tier-1 plugins 2021-05-21 12:03:22 +02:00
Michael Klishin a755dca8e9
MQTT: use consistent Ra operation timeout values
of more than the default 5s which is really low.
2021-05-18 14:35:48 +03:00
Philip Kuryloski c13c2af614 Bazel file refactoring 2021-05-11 12:03:27 +02:00
Philip Kuryloski 36321ee126 Test rabbitmq_mqtt with bazel 2021-04-19 09:50:42 +02:00
Carl Hörberg 681cb78b0d Test that proxy dest address is picked up in all plugins 2021-03-31 11:28:40 +02:00
kjnilsson 62677cbacf
MQTT ra systems changes 2021-03-22 21:44:19 +03:00
Philip Kuryloski a63f169fcb Remove duplicate rabbitmq-components.mk and erlang.mk files
Also adjust the references in rabbitmq-components.mk to account for
post monorepo locations
2021-03-22 15:40:19 +01:00
Michael Klishin 5e0d7041cd
Merge pull request #2910 from rabbitmq/configure-num-conns-sup
Make ranch parameter `num_conns_sups` configurable
2021-03-19 21:59:30 +03:00
dcorbacho a41ece3950 Make ranch parameter `num_conns_sups` configurable
Defaults to 1
rabbit - num_conns_sup
rabbitmq_mqtt - num_conns_sup
rabbitmq_stomp - num_conns_sup
2021-03-18 21:38:13 +01:00
kjnilsson 52f745dcde Update rabbitmq-components.mk
use v1.x branch of ra
2021-03-18 15:14:40 +00:00
Loïc Hoguin d5e3bdd623
Add ADDITIONAL_PLUGINS variable
This allows including additional applications or third party
plugins when creating a release, running the broker locally,
or just building from the top-level Makefile.

To include Looking Glass in a release, for example:

$ make package-generic-unix ADDITIONAL_PLUGINS="looking_glass"

A Docker image can then be built using this release and will
contain Looking Glass:

$ make docker-image

Beware macOS users! Applications such as Looking Glass include
NIFs. NIFs must be compiled in the right environment. If you
are building a Docker image then make sure to build the NIF
on Linux! In the two steps above, this corresponds to Step 1.

To run the broker with Looking Glass available:

$ make run-broker ADDITIONAL_PLUGINS="looking_glass"

This commit also moves Looking Glass dependency information
into rabbitmq-components.mk so it is available at all times.
2021-03-12 12:29:28 +01:00
Michael Klishin 91964db0e6
MQTT: correct a typo in mqtt_machine
Introduced in #2861
2021-03-12 05:33:03 +03:00
Michael Klishin 97ff62d3b2
Drop trailing newlines from logged messages where possible
Lager strips trailing newline characters but OTP logger with the default
formatter adds a newline at the end. To avoid unintentional multi-line log
messages we have to revisit most messages logged.

Some log entries are intentionally multiline, others
are printed to stdout directly: newlines are required there
for sensible formatting.
2021-03-11 15:17:37 +01:00
Jean-Sébastien Pédron cdcf602749
Switch from Lager to the new Erlang Logger API for logging
The configuration remains the same for the end-user. The only exception
is the log root directory: it is now set through the `log_root`
application env. variable in `rabbit`. People using the Cuttlefish-based
configuration file are not affected by this exception.

The main change is how the logging facility is configured. It now
happens in `rabbit_prelaunch_logging`. The `rabbit_lager` module is
removed.

The supported outputs remain the same: the console, text files, the
`amq.rabbitmq.log` exchange and syslog.

The message text format slightly changed: the timestamp is more precise
(now to the microsecond) and the level can be abbreviated to always be
4-character long to align all messages and improve readability. Here is
an example:

    2021-03-03 10:22:30.377392+01:00 [dbug] <0.229.0> == Prelaunch DONE ==
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Starting RabbitMQ 3.8.10+115.g071f3fb on Erlang 23.2.5
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Licensed under the MPL 2.0. Website: https://rabbitmq.com

The example above also shows that multiline messages are supported and
each line is prepended with the same prefix (the timestamp, the level
and the Erlang process PID).

JSON is also supported as a message format and now for any outputs.
Indeed, it is possible to use it with e.g. syslog or the exchange. Here
is an example of a JSON-formatted message sent to syslog:

    Mar  3 11:23:06 localhost rabbitmq-server[27908] <0.229.0> - {"time":"2021-03-03T11:23:06.998466+01:00","level":"notice","msg":"Logging: configured log handlers are now ACTIVE","meta":{"domain":"rabbitmq.prelaunch","file":"src/rabbit_prelaunch_logging.erl","gl":"<0.228.0>","line":311,"mfa":["rabbit_prelaunch_logging","configure_logger",1],"pid":"<0.229.0>"}}

For quick testing, the values accepted by the `$RABBITMQ_LOGS`
environment variables were extended:
  * `-` still means stdout
  * `-stderr` means stderr
  * `syslog:` means syslog on localhost
  * `exchange:` means logging to `amq.rabbitmq.log`

`$RABBITMQ_LOG` was also extended. It now accepts a `+json` modifier (in
addition to the existing `+color` one). With that modifier, messages are
formatted as JSON intead of plain text.

The `rabbitmqctl rotate_logs` command is deprecated. The reason is
Logger does not expose a function to force log rotation. However, it
will detect when a file was rotated by an external tool.

From a developer point of view, the old `rabbit_log*` API remains
supported, though it is now deprecated. It is implemented as regular
modules: there is no `parse_transform` involved anymore.

In the code, it is recommended to use the new Logger macros. For
instance, `?LOG_INFO(Format, Args)`. If possible, messages should be
augmented with some metadata. For instance (note the map after the
message):

    ?LOG_NOTICE("Logging: switching to configured handler(s); following "
                "messages may not be visible in this log output",
                #{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),

Domains in Erlang Logger parlance are the way to categorize messages.
Some predefined domains, matching previous categories, are currently
defined in `rabbit_common/include/logging.hrl` or headers in the
relevant plugins for plugin-specific categories.

At this point, very few messages have been converted from the old
`rabbit_log*` API to the new macros. It can be done gradually when
working on a particular module or logging.

The Erlang builtin console/file handler, `logger_std_h`, has been forked
because it lacks date-based file rotation. The configuration of
date-based rotation is identical to Lager. Once the dust has settled for
this feature, the goal is to submit it upstream for inclusion in Erlang.
The forked module is calld `rabbit_logger_std_h` and is based
`logger_std_h` in Erlang 23.0.
2021-03-11 15:17:36 +01:00
dcorbacho 61f7b2a723 Update to ranch 2.0 2021-03-08 23:11:05 +01:00
Michael Klishin b6c4831e75
Bump Lager to 3.9.1 2021-03-04 04:36:39 +03:00
Loïc Hoguin 66ac1bf5e9
Bump observer_cli to 1.6.1
More responsive when the system is overloaded with file calls.
2021-03-01 21:55:27 +03:00
Michael Klishin 8fe3df9343
Upgrade Lager to 3.9.0 for OTP 24 compatibility
`lager_util:expand_path/1` use changes are
due to erlang-lager/lager#540
2021-02-26 00:52:15 +03:00
Michael Klishin f73e851f9c
Bump observer_cli to 1.6.0 2021-02-24 12:53:55 +03:00
Michael Klishin a5098b28a7
Bump Lager to 3.8.2 for OTP 24 compatibility 2021-02-24 12:53:30 +03:00
Michael Klishin b11a79cccf
Bump (c) year in header files 2021-02-04 07:04:58 +03:00
Arnaud Cogoluègnes b921ac11a8
Merge pull request #2712 from rabbitmq/rabbitmq-stream-prometheus
Add stream prometheus plugin
2021-01-27 16:46:37 +01:00
Michael Klishin 52479099ec
Bump (c) year 2021-01-22 09:00:14 +03:00
Arnaud Cogoluègnes b5315c0166
Merge branch 'master' into rabbitmq-stream-prometheus 2021-01-18 11:26:06 +01:00
Michael Klishin e8fccbaf48
MQTT auth_SUITE: synchronise concurrent setup with the test 2021-01-13 16:41:03 +03:00
Arnaud Cogoluègnes bf72683eb2
Add stream prometheus plugin 2021-01-11 16:49:56 +01:00
Arnaud Cogoluègnes cbd3c8dfdd
Merge branch 'master' into rabbitmq-stream-management 2021-01-04 09:50:47 +01:00
kjnilsson 04a55e0ee6 bug fixes 2020-12-22 15:16:17 +00:00
kjnilsson 160e41687d MQTT machine versions 2020-12-22 10:21:21 +00:00
kjnilsson 067a42e066 Optimise MQTT state machine
It was particularly slow when processing down commands.
2020-12-21 15:58:32 +00:00
Arnaud Cogoluègnes 224e9914b2
Merge branch 'master' into rabbitmq-stream-management 2020-12-04 10:26:42 +01:00
kjnilsson 6fdb7d29ec Handle errors in crashing_queues_SUITE
As the connection may crash during the previous declaration and a caught
error would be returned in amqp_connection:open_channel/1 that wasn't
handled previously. Exactly how things fail in this test is most likely
very timing dependent and may vary.

Also fixes mqtt test where the process that set up a mock auth ETS table
was transient when an rpc timeout was introduced
2020-12-03 13:56:09 +00:00
Arnaud Cogoluègnes 23d7e8114c
Introduce stream management plugin 2020-11-19 14:48:25 +01:00
Jean-Sébastien Pédron 47686ee1f0
Remove unused .github directories
They were valid until the switch to the "monorepository" when everything
was merged into a single Git repository.
2020-11-17 13:33:16 +01:00
Arnaud Cogoluègnes 07125203b9 Update rabbitmq-components.mk 2020-11-03 14:27:43 +01:00
Michael Klishin 89235cb9fc Update rabbitmq-components.mk 2020-10-21 12:55:39 +03:00
Michael Klishin 79a02256f1 Merge pull request #238 from rabbitmq/auth-attempt-metrics
Add auth attempt metrics
2020-10-14 23:56:29 +03:00
dcorbacho d80e8e1bec Add protocol to auth attempt metrics 2020-09-23 11:16:13 +01:00
Luke Bakken 1daae3064d Revert "Switch to classic OTP supervisor for two modules"
This reverts commit 1bead422a9.
2020-08-31 15:51:39 -07:00
Luke Bakken abb0ab5bd9 Revert "Closes #233"
This reverts commit c45b8d813a.
2020-08-31 15:50:32 -07:00
dcorbacho b138241b52 Add auth attempt metrics 2020-08-28 13:19:05 +01:00
Luke Bakken 65937d3b15 Update rabbitmq-components.mk 2020-08-04 08:41:48 -07:00
Jean-Sébastien Pédron 7d7c8e11d2 Update rabbitmq-components.mk 2020-07-30 12:06:54 +02:00
Luke Bakken f92e4b24ca Update rabbitmq-components.mk 2020-07-29 10:02:04 -07:00
dcorbacho 40e2e3fb13 Update erlang.mk 2020-07-21 14:33:00 +01:00
Michael Klishin 3cc3974f82 Update rabbitmq-components.mk 2020-07-21 13:12:50 +03:00
Michael Klishin 05d99be34e Update rabbitmq-components.mk 2020-07-21 03:43:02 +03:00
dcorbacho 99bf86bb87 Revert drop of Exhibit B on MPL 2.0 2020-07-20 17:01:38 +01:00
dcorbacho e92f7999a2 Update LICENSE 2020-07-20 11:43:03 +01:00
Michael Klishin 4b33266425 Update MPL2 license file, drop Exhibit B
and add a VMware copyright notice.

We did not mean to make this code Incompatible with Secondary Licenses
as defined in [1].

1. https://www.mozilla.org/en-US/MPL/2.0/FAQ/
2020-07-17 14:53:09 +03:00
dcorbacho dae65d8e8d Merge branch 'master' into rabbitmq-server-2321 2020-07-14 15:48:30 +01:00
D Corbacho 1a9632576d Merge pull request #236 from rabbitmq/switch-to-MPL-2.0
Switch to Mozilla Public License 2.0 (MPL 2.0)
2020-07-13 17:40:24 +01:00
dcorbacho 119eb99e8d Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-13 17:39:36 +01:00
Michael Klishin 30e6cbdd24 Extract rabbit_networking:stop_ranch_listener_of_protocol/1
Part of rabbitmq/rabbitmq-server#2321
2020-07-09 22:02:09 +03:00
kjnilsson 3cf84a19b2 Fix mqtt_machine crash bug
When a client performs repeated requests the state machine would crash
with a match exception.

Add unit test suite for mqtt_machine.
2020-07-09 14:41:00 +01:00
Michael Klishin d7474cee33 Cosmetics 2020-07-08 20:00:00 +03:00
Michael Klishin 13cbcfff79 Cosmetics 2020-07-08 19:21:21 +03:00
Michael Klishin 033128cb35 Make sure MQTT plugin closes its connections when a node is put into maintenance mode
Part of rabbitmq/rabbitmq-server#2321
2020-07-08 19:10:54 +03:00
Michael Klishin 73ed4d3772 Unify Ranch ref construction for all listeners
This makes the refs predictable and easy to compute
from a listener record. Then suspending all listeners
becomes a lot simpler.

While at it, make protocol applications clean up
their listeners when they stop. This way tests
and other callers that have to stop the app
would not need to know anything about
its listeners.

Part of rabbitmq/rabbitmq-server#2321
2020-06-24 04:27:34 +03:00
Jean-Sébastien Pédron 378b6719e4 Update erlang.mk 2020-06-23 17:14:34 +02:00
Michael Klishin c45b8d813a Closes #233 2020-06-18 03:32:35 +03:00
Michael Klishin 1bead422a9 Switch to classic OTP supervisor for two modules
supervisor2 features are not needed there, so why not use
the standard thing that's evolving together with Erlang/OTP.

Part of #233.
2020-06-18 03:04:13 +03:00
Michael Klishin 6280926bb2 Bump Recon to 2.5.1
for Erlang 23 compatibility of 'rabbitmq-diagnostics observer'

References zhongwencool/observer_cli#68.
2020-06-09 08:22:16 +03:00
Michael Klishin ae37b4723a Use a higher Ra operation timeout 2020-06-02 21:37:14 +03:00
Jean-Sébastien Pédron dcc5f7b553 Update copyright (year 2020) 2020-03-10 16:39:48 +01:00
Gerhard Lazu 30d4f0a4e5 Update rabbitmq-components.mk 2020-03-06 09:19:17 +00:00
Gerhard Lazu 64db4888d1 Update erlang.mk 2020-03-06 09:18:01 +00:00
Jean-Sébastien Pédron f48167a514 Travis CI: Update config from rabbitmq-common 2020-03-04 14:24:30 +01:00
Jean-Sébastien Pédron 3f09bfb1f3 Travis CI: Update config from rabbitmq-common 2020-03-04 11:17:16 +01:00
Jean-Sébastien Pédron 9e8def2ed5 Travis CI: Update config from rabbitmq-common 2020-03-03 14:53:39 +01:00
Jean-Sébastien Pédron 2b62f489dc Travis CI: Refresh config patch 2020-03-03 14:30:05 +01:00
Michael Klishin 8b638f413a Avoid using erlang:get_stacktrace/0 for improved OTP 23/24 compat
(cherry picked from commit 251a40f705)
2020-02-27 22:34:56 +03:00
Michael Klishin ed5c1c954a Randomized Raft node startup delay
Same fundamental idea as Raft itself uses to avoid
cluster fragmentation on parallel node boot.

(cherry picked from commit f8a9b4b8b6)
2020-02-26 02:23:33 +03:00
Michael Klishin bbc170af7b Synchronise plugin start with that of Raft node
While at it, start listeners after the client ID
tracker is ready. Otherwise we run the risk of taking
client connections in before they can be accepted.

(cherry picked from commit 5da74b6e82)
2020-02-26 02:23:26 +03:00
Michael Klishin e6a8d93bb5 Inject a delay before joining client ID tracking cluster
We have considered multiple options in preventing a split cluster
scenario when N nodes a started in parallel and are initially unaware of
each other. They all are fairly involved and run various risks, e.g.
of losing consistency for cluster members that need to rejoin a newly
discovered set of members.

A simple delay to see if there may be any peers seems to be a straightfoward
solution that would make a practical difference.

In the future consistent client ID tracking should be a feature the user
can opt out of because it tilts MQTT plugin potentially to far towards
C on the consistency/availability range.

Pair: @kjnilsson
2020-02-24 17:58:03 +03:00
Michael Klishin 377752d003 Ignore client ID tracker timeouts on connection closure
There isn't much to do about those at this stage in the connection
lifecycle anyway.
2020-02-21 21:42:39 +03:00
Gerhard Lazu 72887dbd52 Update rabbitmq-components.mk 2020-02-11 15:31:46 +00:00
kjnilsson eadf5f7094 Make interactions with Ra async
To avoid blocking when registering or unregistering a client id. This is
ok as informing the current connection holder of the client id is
already async. This should be more scalable and provide much better MQTT
connection setup latency.
2020-02-10 17:28:18 +00:00
Michael Klishin 2927f473ce (c) bump 2019-12-29 05:50:32 +03:00
Jean-Sébastien Pédron 3af67f744b Git: Ignore copied CLI 2019-12-12 15:00:20 +01:00
Jean-Sébastien Pédron a188885008 Update rabbitmq-components.mk 2019-12-12 13:14:55 +01:00
Michael Klishin cf9e258d49 Make it possible to override client ID in some tests 2019-11-25 17:37:50 +03:00
Michael Klishin ddb00edbeb Merge pull request #217 from velimir/cache-topic-access
cache topic access
2019-11-07 22:51:17 +00:00
Grigory Starinkin a337839983 limit topic permission cache size 2019-11-07 14:40:10 +00:00
Grigory Starinkin 8c29181b7b cache topic permission access
performance optimisation
2019-11-07 14:39:43 +00:00
Grigory Starinkin 549579e595 cache topic translation results
performance optimisation
2019-11-07 14:36:14 +00:00
Michael Klishin 92edaa716e Update .travis.yml 2019-11-05 17:24:16 +00:00
Michael Klishin 5947ac6961 Use a topic name that has R and W permissions 2019-11-05 17:07:55 +00:00
Michael Klishin 35a99a24a2 Downgrade QoS 2 to QoS 1 when sending Last Will
Closes #214.
2019-11-05 16:54:20 +00:00
Jean-Sébastien Pédron 26995315c6 rabbit_mqtt_collector: Pass several node IDs to ra:query_leader()
... instead of the local node ID only.

In CI, after an MQTT node is decommissioned (using `rabbitmqctl
decommission_mqtt_node`), `ra:query_leader()` with the local node ID
may return `{error, noproc}`.

Giving this function all the node IDs fixes the problem because Ra tries
all node IDs in turn until one responds.
2019-10-29 10:18:03 +01:00
Michael Klishin ab1b923794 (c) year 2019-10-22 13:31:13 +03:00
Arnaud Cogoluègnes 26a17e8530 Modernize Java test suite
Migrate to JUnit 5, use TestInfo to create test-related MQTT
client ID when possible, remove Awaitility in favor of a in-house
utility and the use of lambdas, clean some code.
2019-09-23 14:43:40 +02:00
Luke Bakken e8c9b6d118 Remove two unnecessary class variables 2019-09-20 15:51:39 -07:00
Luke Bakken a07c231891 Ensure each test has a meaningful client id 2019-09-20 15:44:28 -07:00
Luke Bakken 2141339a80 Remove another snowflake topic 2019-09-20 09:16:04 -07:00
Luke Bakken 13f881e6e3 Remove another snowflake topic 2019-09-20 05:22:16 -07:00
Luke Bakken e19deefc14 Remove "mid" topic and replace with test-topic 2019-09-20 05:01:29 -07:00
Luke Bakken 60ac7affa5 Use per-testcase instance of TestMqttConnectOptions 2019-09-19 17:12:55 -07:00
Luke Bakken 54a3ab1666 Formatting 2019-09-19 16:37:05 -07:00
Luke Bakken a487dc427a Fix willIsRetained test 2019-09-19 11:39:48 -07:00
Luke Bakken d92c60e882 Fixed the lastWillNotSentOnRestrictedTopic test 2019-09-19 11:17:13 -07:00
Luke Bakken d8669f7bc0 Increase debug level
One test fixed at least
2019-09-19 10:00:43 -07:00
Michael Klishin b94ceeb398 Java integration suite: reduce use of shared mutable state
Per discussion with @acogoluegnes.
2019-09-19 15:26:21 +03:00
Michael Klishin 4755325f19 An attempt to avoid Paho Java state exceptions 2019-09-19 11:39:58 +03:00
Michael Klishin 286e60b08f Ignore IDEA project files 2019-09-19 10:30:20 +03:00
Michael Klishin 82f526baed New Paho version does not handle null passwords 2019-09-19 10:28:39 +03:00
Michael Klishin 103dc2c5eb Bump RabbitMQ and Paho clients used in tests 2019-09-19 09:26:26 +03:00
kjnilsson 1cb43f9a7d Update rabbitmq-components.mk 2019-09-13 10:24:25 +01:00
Luke Bakken 92f1ca1971 Rename sparkplug_b to sparkplug 2019-09-06 08:58:04 -07:00
Arnaud Cogoluègnes 2ffa74e262 Disable Sparkplug support by default
References #206
2019-09-06 15:08:57 +02:00
Arnaud Cogoluègnes f0ef67e2fc Use AMQP topic name in translation test
References #206
2019-09-06 15:07:29 +02:00
Luke Bakken 061651f31e Correctly set topic permissions for sparkplug B prefix, and use correct topics in test 2019-09-04 10:24:47 -07:00
Luke Bakken d0c0ec33ff Use new translation funs in library 2019-09-04 08:07:33 -07:00
Luke Bakken e7554def0a Topic translation CT tests pass 2019-09-04 07:43:35 -07:00
Luke Bakken 8e1ddac03d Add CT tests for topic translation funs, failing currently 2019-09-04 07:43:35 -07:00
Luke Bakken e05d0e2dbd Use string: functions rather than regexes 2019-09-04 07:43:35 -07:00
Luke Bakken b60582d0fb Start working on MQTT/AMQP translation funs that take sparkplug into account 2019-09-04 07:43:35 -07:00
Luke Bakken 04fcd898ca Add failing test involving MQTT/Sparkplug B and AMQP interop 2019-09-04 07:43:35 -07:00
Luke Bakken 88bf29e7b3 Fix test for mqtt.sparkplug_b 2019-09-04 07:43:35 -07:00
Luke Bakken e0504e7617 Add failing test for mqtt.sparkplug_b schema element 2019-09-04 07:43:35 -07:00
kjnilsson 52dbc4206c Update rabbitmq-components.mk 2019-09-04 10:31:03 +01:00
Michael Klishin d821e1cacb Merge pull request #204 from rabbitmq/vhost-description
Use `rabbit_vhost:list_names/0'
2019-08-30 13:09:18 +03:00
kjnilsson 41d53deaf1 remove unused header 2019-08-30 10:47:08 +01:00
Diana Corbacho 206f28ba65 Use `rabbit_vhost:list_names/0'
[#166298298]
2019-08-30 11:00:53 +02:00
Jean-Sébastien Pédron 158eb42c93 Update erlang.mk 2019-08-29 20:45:31 +02:00
Jean-Sébastien Pédron 2f35106928 Makefile: Don't set `$(ELIXIR_LIB_DIR)` here
It is already managed by `rabbitmq-build.mk`.
2019-08-14 11:19:21 +02:00
Michael Klishin dd259d0455 Update rabbitmq-components.mk 2019-08-11 01:48:00 +10:00
Jean-Sébastien Pédron 90642c0fe9 Update erlang.mk 2019-08-02 09:54:18 +02:00
Michael Klishin deb78e9c06 Update rabbitmq-components.mk 2019-08-01 17:13:21 +03:00
Arnaud Cogoluègnes c403200bad Do not reach out to all nodes when listing connections
The way connections are listed already contains all the connections, so
there is no need to reach out to all cluster nodes and aggregate the
results, as it results in duplicate lines.

The command test now uses a cluster to make sure connections are listed
properly in a cluster.

[#167639960]

Fixes #202
2019-08-01 09:29:16 +02:00
Michael Klishin 6bdc227900 Squash a couple of warnings 2019-07-31 07:47:44 +03:00
Michael Klishin 7081ecb918 Avoid performing a Ra operation on an empty list of nodes
That fails with a function clause.
2019-07-30 20:35:44 +03:00
Michael Klishin abe5abf48c Use a tick timeout value connected to node's nettick
Quorum queues do that and it makes more sense than a hardcoded,
subsystem-specific value.
2019-07-30 05:51:25 +03:00
Michael Klishin cacd557740 Log connection errors as such 2019-07-29 17:27:27 +03:00
Michael Klishin 5c7fe2cc7b Use more diverse return values from process_request for CONNECT
A drive-by change discovered with @kjnilsson while pairing
on #200.
2019-07-29 16:59:19 +03:00
Michael Klishin baf51aa146 This list is a list of compatible peers
It cannot contain our own node, so the match
fails and a new leader election is never started,
so client ID tracking cluster does not start.
2019-07-29 15:09:45 +03:00
Michael Klishin 2192861ffe Return an empty list of client IDs if Raft cluster query times out 2019-07-26 22:31:06 +03:00
Michael Klishin 091127a422 Make sure client ID tracker can rejoin the cluster
Previously it could time out waiting for a peer to
become available in certain node shutdown/restart
scenarios.

Pair: @kjnilsson.

Closes #200.
2019-07-26 20:20:24 +03:00
Arnaud Cogoluègnes 1938920fad Update rabbitmq-components.mk 2019-07-09 16:06:03 +02:00
Michael Klishin 7d8d7c491c Return false here as this module does not provide an update_state/2 2019-07-02 16:27:10 +02:00
Arnaud Cogoluègnes 689a557c4c Add state_can_expire/0 to mock authn/authz backend
References rabbitmq/rabbitmq-auth-backend-oauth2#28
2019-07-02 15:50:12 +02:00
Jean-Sébastien Pédron f3647910b1 Update rabbitmq-components.mk 2019-06-28 16:05:35 +02:00
Jean-Sébastien Pédron 38265434d5 Update erlang.mk 2019-06-28 16:02:24 +02:00
Jean-Sébastien Pédron 437bb5da96 Java testsuite: Use a third RabbitMQ node for the cluster-wide client ID tracking test
This is to ensure that the test can pass in a mixed-versions cluster
where odd-numbered nodes might not support clsuter-wide client ID
tracking (RabbitMQ 3.7.x).
2019-06-12 16:29:38 +02:00
Jean-Sébastien Pédron cf082aa6fd test/java_SUITE_data/pom.xml: Make it compatible with Java 12 2019-06-12 16:29:06 +02:00
Jean-Sébastien Pédron 3c111a18be mqtt_node: Skip incompatible nodes when configuring Ra cluster
In the cluster_SUITE testsuite:

All even-numbered nodes will use the same code base when using a
secondary Umbrella. Odd-numbered nodes might use an incompatible code
base. When cluster-wide client ID tracking was introduced, it was not
put behind a feature flag because there was no need for one. Here, we
don't have a way to ensure that all nodes participate in client ID
tracking. However, those using the same code should. That's why we
limit our RPC calls to those nodes.

That's also the reason why we use a 5-node cluster: with node 2 and
4 which might not participate, it leaves nodes 1, 3 and 5: thus 3
nodes, the minimum to use Ra in proper conditions.

References #91, #195.
[#135330629]
2019-06-11 18:26:27 +02:00
Jean-Sébastien Pédron 391c44c665 rabbit_auth_backend_mqtt_mock: Move this test module to `test/` 2019-06-11 16:15:10 +02:00
Jean-Sébastien Pédron 8de6ab7e81 cluster_SUITE: Bump suite timestrap to 5 minutes
One minute seems too short for those tests in CI.
2019-06-11 13:52:05 +02:00
Michael Klishin e900354db5 Merge pull request #195 from rabbitmq/rabbitmq-mqtt-91
Cluster-wide MQTT client id tracking
2019-06-11 01:32:20 +03:00
Michael Klishin 91d3d72bf8 Refactor 2019-06-11 01:31:44 +03:00
Michael Klishin 91a6252cff More tests 2019-06-11 01:26:07 +03:00
Arnaud Cogoluègnes 85e2755c9a Add mock auth backend
References rabbitmq/rabbitmq-server#1767
2019-06-06 13:16:14 +02:00
Arnaud Cogoluègnes 7f8708bd85 Add test to check client id propagation
This commit adds a test to check the MQTT client is properly propagated
to the authentication and authorization backends.

References rabbitmq/rabbitmq-server#1767
2019-06-06 10:46:31 +02:00
Michael Klishin 5e81c4ea83 Compile 2019-06-04 19:13:12 +03:00
Michael Klishin 5725a21015 Remonitor connections on short disconnects and after recovery 2019-06-04 17:19:32 +03:00
Michael Klishin 2107daf93f Remove a clause that's no longer used 2019-06-04 16:34:22 +03:00
Michael Klishin 129d92b431 Do not snapshot when a new client is registered 2019-06-04 16:33:48 +03:00
Michael Klishin bfa7f332c0 Only emit snapshot effects when client ID map changes 2019-06-04 13:54:34 +03:00
Michael Klishin 1434eb991b Switch rabbit_mqtt_collector:list/0 to use a leader query
While at it, improve error handling around client ID
collector unavailability.
2019-06-04 13:40:26 +03:00
Michael Klishin f4f65867ea Client tracking: notify existing connections in a one-off process
To avoid blocking the leader even a little bit.
Per suggestion from @kjnilsson.
2019-06-04 12:25:09 +03:00
Michael Klishin c5ccd7b4ac A typo 2019-06-04 03:24:20 +03:00
Michael Klishin e220b896d2 decommission_mqtt_node only belongs to the ctl scope 2019-06-04 03:15:42 +03:00
Michael Klishin f0d9bf8d8e decomission_mqtt_node: wording 2019-06-04 02:11:37 +03:00
Michael Klishin 4130c2cc8c Consistency 2019-06-04 02:11:06 +03:00
Michael Klishin d86390453a Correct a typo 2019-06-04 02:00:36 +03:00
Michael Klishin 16850a954f Client ID tracking: make more transitions leader node-only 2019-06-04 01:57:27 +03:00
Michael Klishin 769089b6d8 Wording 2019-06-04 01:56:56 +03:00
Michael Klishin 9c07491ddc Define a state_enter/2 fun to clean up on disk state
A freshly started node by definition wouldn't have any
connections. This is a Ra-idiomatic way of cleaniing up
on disk state that involves pids.

Per recommendation from @kjnilsson.
2019-06-04 00:45:53 +03:00
Michael Klishin 2613595b5e Use a function call effect
so that this state transition applied on the leader node only.
2019-06-04 00:44:45 +03:00
Michael Klishin e004f0bb91 Do not unregister a client ID if it does not belong to the terminating connection
Due to the LWW [A] semantics of duplicate client ID handling there might
be another process register with the client ID by the time a client
is disconnected and has to be unregistered. Consider the following
scenario:

1. Client A connects, client ID map is updated and now contains
   a new entry with A's pid
2. Client B connects, client ID map is updated and now contains
   an updated entry with B's pid
3. B disconnects, `rabbit_mqtt_collector:unregister/2` deletes
   the entry in the client IDs map
4. The map is empty, even though one client still has to be connected
5. Client A reconnects and duplicate client ID is
   not detected by `rabbit_mqtt_collector:register/2`

A. Last Write Wins
2019-06-03 16:05:14 +03:00
Michael Klishin 4215d2e7a5 Logging: mention client ID when accepting a connection 2019-06-03 15:24:35 +03:00
Diana Corbacho 9e1d1f577a Add forgotten files
[#135330629]
2019-06-03 10:24:12 +02:00
Michael Klishin 288d9dc7ee Merge branch 'master' into rabbitmq-mqtt-91 2019-06-03 09:58:15 +03:00
Gerhard Lazu 25c111a726 Update rabbitmq-components.mk 2019-06-03 02:23:41 +01:00
Jean-Sébastien Pédron d9cc2a6623 Update rabbitmq-components.mk 2019-05-17 15:17:22 +02:00
Michael Klishin 521093e588 Update rabbitmq-components.mk 2019-05-17 08:36:54 +03:00
Diana Corbacho 32200bb352 Change banner
[#135330629]
2019-05-16 20:47:55 +01:00
Diana Corbacho 7bfe632cb6 Cluster-wide MQTT client id tracking
Uses a ra cluster to keep the client id tracking information - in
the state of the ra machine.

If nodes are decommissioned from the RMQ cluster, the command
decommission_mqtt_node must be invoked first to disconnect the clients
on that node and remove the node from the ra cluster.

[#135330629]
2019-05-16 17:50:06 +01:00
Michael Klishin 2e35f9b7c2 Update rabbitmq-components.mk 2019-05-14 11:50:54 +03:00
Michael Klishin 307411067e Update rabbitmq-components.mk 2019-05-13 16:40:38 +03:00
Gerhard Lazu 3e17e1a80d Update rabbitmq-components.mk 2019-05-01 13:18:18 +01:00
Luke Bakken 1596ef9ae5 Update rabbitmq-components.mk 2019-04-30 16:21:00 -07:00
Jean-Sébastien Pédron 5050e66b63 Update rabbitmq-components.mk 2019-04-30 14:47:34 +02:00
Gerhard Lazu 2e4451a8ef Update rabbitmq-components.mk 2019-04-22 21:55:09 +01:00
Michael Klishin 71563a65d8 CLI tool: wording 2019-03-26 20:32:40 +03:00
Michael Klishin 8ab9f8ff6d CLI commands: provide more information to the new help command 2019-03-26 20:29:56 +03:00
Spring Operator 96006cd58b URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 1 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
2019-03-21 03:17:58 -05:00
Spring Operator 852c61ea99 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# HTTP URLs that Could Not Be Fixed
These URLs were unable to be fixed. Please review them to see if they can be manually resolved.

* http://blog.listincomprehension.com/search/label/procket (200) with 1 occurrences could not be migrated:
   ([https](https://blog.listincomprehension.com/search/label/procket) result ClosedChannelException).
* http://dozzie.jarowit.net/trac/wiki/TOML (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/TOML) result SSLHandshakeException).
* http://dozzie.jarowit.net/trac/wiki/subproc (200) with 1 occurrences could not be migrated:
   ([https](https://dozzie.jarowit.net/trac/wiki/subproc) result SSLHandshakeException).
* http://e2project.org (200) with 1 occurrences could not be migrated:
   ([https](https://e2project.org) result AnnotatedConnectException).
* http://nitrogenproject.com/ (200) with 2 occurrences could not be migrated:
   ([https](https://nitrogenproject.com/) result ConnectTimeoutException).
* http://proper.softlab.ntua.gr (200) with 1 occurrences could not be migrated:
   ([https](https://proper.softlab.ntua.gr) result SSLHandshakeException).
* http://yaws.hyber.org (200) with 1 occurrences could not be migrated:
   ([https](https://yaws.hyber.org) result AnnotatedConnectException).
* http://choven.ca (503) with 1 occurrences could not be migrated:
   ([https](https://choven.ca) result ConnectTimeoutException).

# Fixed URLs

## Fixed But Review Recommended
These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended.

* http://fixprotocol.org/ (301) with 1 occurrences migrated to:
  https://fixtrading.org ([https](https://fixprotocol.org/) result SSLHandshakeException).
* http://erldb.org (UnknownHostException) with 1 occurrences migrated to:
  https://erldb.org ([https](https://erldb.org) result UnknownHostException).

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://cloudi.org/ with 27 occurrences migrated to:
  https://cloudi.org/ ([https](https://cloudi.org/) result 200).
* http://erlware.org/ with 1 occurrences migrated to:
  https://erlware.org/ ([https](https://erlware.org/) result 200).
* http://inaka.github.io/cowboy-trails/ with 1 occurrences migrated to:
  https://inaka.github.io/cowboy-trails/ ([https](https://inaka.github.io/cowboy-trails/) result 200).
* http://ninenines.eu with 6 occurrences migrated to:
  https://ninenines.eu ([https](https://ninenines.eu) result 200).
* http://www.actordb.com/ with 2 occurrences migrated to:
  https://www.actordb.com/ ([https](https://www.actordb.com/) result 200).
* http://www.cs.kent.ac.uk/projects/wrangler/Home.html with 1 occurrences migrated to:
  https://www.cs.kent.ac.uk/projects/wrangler/Home.html ([https](https://www.cs.kent.ac.uk/projects/wrangler/Home.html) result 200).
* http://www.rabbitmq.com/mpl.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/mpl.html ([https](https://www.rabbitmq.com/mpl.html) result 200).
* http://www.rabbitmq.com/mqtt.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/mqtt.html ([https](https://www.rabbitmq.com/mqtt.html) result 200).
* http://www.rebar3.org with 1 occurrences migrated to:
  https://www.rebar3.org ([https](https://www.rebar3.org) result 200).
* http://contributor-covenant.org with 1 occurrences migrated to:
  https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301).
* http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to:
  https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301).
* http://inaka.github.com/apns4erl with 1 occurrences migrated to:
  https://inaka.github.com/apns4erl ([https](https://inaka.github.com/apns4erl) result 301).
* http://inaka.github.com/edis/ with 1 occurrences migrated to:
  https://inaka.github.com/edis/ ([https](https://inaka.github.com/edis/) result 301).
* http://lasp-lang.org/ with 1 occurrences migrated to:
  https://lasp-lang.org/ ([https](https://lasp-lang.org/) result 301).
* http://saleyn.github.com/erlexec with 1 occurrences migrated to:
  https://saleyn.github.com/erlexec ([https](https://saleyn.github.com/erlexec) result 301).
* http://www.mozilla.org/MPL/ with 27 occurrences migrated to:
  https://www.mozilla.org/MPL/ ([https](https://www.mozilla.org/MPL/) result 301).
* http://www.rabbitmq.com/man/rabbitmq-plugins.1.man.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/man/rabbitmq-plugins.1.man.html ([https](https://www.rabbitmq.com/man/rabbitmq-plugins.1.man.html) result 301).
* http://zhongwencool.github.io/observer_cli with 1 occurrences migrated to:
  https://zhongwencool.github.io/observer_cli ([https](https://zhongwencool.github.io/observer_cli) result 301).
2019-03-20 03:18:59 -05:00
Michael Klishin 847e27b83f Travis: use Erlang 21.3, Elixir 1.8.1 2019-03-20 10:33:17 +03:00
Spring Operator c90ca44234 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://maven.apache.org/xsd/maven-4.0.0.xsd with 1 occurrences migrated to:
  https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200).

# Ignored
These URLs were intentionally ignored.

* http://maven.apache.org/POM/4.0.0 with 2 occurrences
* http://www.w3.org/2001/XMLSchema-instance with 1 occurrences
2019-03-19 20:10:10 -05:00
Michael Klishin fe51f5d4e5 Additional help content for CLI command 2019-03-19 20:34:58 +03:00
Daniil Fedotov e7fd8ce1b4 Handle 21.3 tls_alert error format. 2019-03-18 18:33:52 -04:00
Michael Klishin 2b3b697db3 Update rabbitmq-components.mk 2019-03-15 09:34:42 +03:00
Michael Klishin ec18c091c2 Update rabbitmq-components.mk 2019-03-15 05:05:51 +03:00
Spring Operator 7e218211b8 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://www.apache.org/licenses/LICENSE-2.0 migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
* http://www.rabbitmq.com migrated to:
  https://www.rabbitmq.com ([https](https://www.rabbitmq.com) result 200).

# Ignored
These URLs were intentionally ignored.

* http://maven.apache.org/POM/4.0.0
* http://maven.apache.org/xsd/maven-4.0.0.xsd
* http://www.w3.org/2001/XMLSchema-instance
2019-03-11 21:54:05 -05:00
Michael Klishin 358c8c97cc Wording 2019-02-21 20:29:14 +03:00
Daniil Fedotov afa6729b1d Description for help command.
Requires https://github.com/rabbitmq/rabbitmq-cli/pull/316
2019-02-20 14:24:30 -05:00
Michael Klishin bcb25da3ce Update rabbitmq-components.mk 2019-02-12 23:24:00 +03:00
Michael Klishin 0d747b18df Wording 2019-02-08 01:58:27 +03:00
Luke Bakken 2f205cc21a Handle duplicate CONNECT frame
Fixes #179

Uses undefined MQTT return code 255 to mean "duplicate auth attempt"

Treat duplicate CONNECT / login like a real connect
2019-02-07 12:49:24 -08:00
Michael Klishin 530cf87095 Handle socket write failures and log them
...instead of letting connection proceesses terminate and
the runtime to log scary looking crash reports.

STOMP has been doing this without logging for a while:

 * https://github.com/rabbitmq/rabbitmq-stomp/blame/v3.7.x/src/rabbit_stomp_reader.erl#L344
 * https://github.com/rabbitmq/rabbitmq-stomp/blob/v3.7.x/src/rabbit_stomp_processor.erl#L1167

Note that otherwise connection error handling is not affected
by this change.

While at it, added more debug logging.

Per discussion with @lukebakken.

References rabbitmq/rabbitmq-server#1862.
2019-02-05 02:49:36 +03:00
Michael Klishin 48bac2500a Formatting 2019-02-03 20:09:41 +03:00
Michael Klishin 9caf40afa1 Cosmetics 2019-02-03 19:43:44 +03:00
Ryan Sandbach 08f97b9e6f New tests for retainer translation. 2019-02-01 00:21:10 -05:00
Ryan Sandbach 563e6529c0 Use translation for retained messages. 2019-02-01 00:20:27 -05:00
Arnaud Cogoluègnes ec65574e1f Add client ID to connection metadata
[#153246723]

Fixes #152
2019-01-22 10:30:25 +01:00
Michael Klishin 1039a21349 .travis.yml: use 21.2 as 21.2.2 builds are no available 2019-01-14 01:20:23 +03:00
Michael Klishin 75d2b49303 .travis.yml: sync Erlang and Elixir versions, require Erlang/OTP 21.2 2019-01-13 05:50:02 +03:00
Luke Bakken 5293a3093e Update rabbitmq-components.mk 2019-01-09 12:55:12 -08:00
Luke Bakken 198d62a64f Update rabbitmq-components.mk 2019-01-08 11:58:31 -08:00
Michael Klishin 16d262f908 Additional tests extracted from rabbitmq/rabbitmq-stomp#130
The settings are already supported by this plugin.
2019-01-02 20:36:51 +03:00
Michael Klishin e25aaba832 Revert "Revert "Use {active,once} instead of async_recv""
This reverts commit e064ace943.

The change to {active, once} ended up being unrelated; it's a bug
in the Erlang 21.2 ssl app.
2018-12-22 10:09:32 +03:00
Michael Klishin e064ace943 Revert "Use {active,once} instead of async_recv"
This reverts commit 70ca23a505.

Due to obscure CI failures in rabbitmq-[web-]stomp.
2018-12-21 21:27:25 +03:00
Loïc Hoguin 70ca23a505 Use {active,once} instead of async_recv 2018-12-18 12:51:14 +01:00
Loïc Hoguin 160e2fb12c Remove a duplicate control_throttle
The function is already called before calling
process_received_bytes, there doesn't seem to
be a reason to call it again.
2018-12-11 15:00:03 +01:00
Michael Klishin 7269ef09d5 Update rabbitmq-components.mk 2018-12-06 18:28:55 +03:00
Loïc Hoguin 7e09b85426 Allow giving the peer address directly for initial_state
Changes initial_state/4 to initial_state/5 to add the peer
address that needs to be provided by Web MQTT. This function
was only used locally and by Web MQTT.
2018-12-04 14:50:32 +01:00
Loïc Hoguin e26c15f047 Use the built-in Ranch PROXY protocol support 2018-12-04 13:15:33 +01:00
Jean-Sébastien Pédron 024b8fc32c Update rabbitmq-components.mk 2018-11-30 14:56:53 +01:00
Jean-Sébastien Pédron b6c2461b11 Update rabbitmq-components.mk 2018-11-22 09:19:38 +01:00
Arnaud Cogoluègnes f1c1dbf30d Use Maven wrapper for Java test suite
This avoids depending on a local Maven.
2018-11-06 11:46:12 +01:00
Arnaud Cogoluègnes 9043d97f60 Fix Maven tests for CI environment
OpenJDK 1.8.0_181 on Debian-based distros introduces a bug that breaks
the Maven Surefire plugin (test plugin). This commit adds an argument to
the plugin configuration to fix this problem. It also bumps some Java
dependencies.
2018-11-06 11:31:18 +01:00
kjnilsson 9a4de20eb1 Update rabbitmq-components.mk 2018-10-29 12:43:25 +00:00
Luke Bakken 2824fdbf1e comment 2018-10-11 07:07:23 -07:00
Michael Klishin 50dfaaa237 Use 10 TLS connection acceptors by default
Part of rabbitmq/rabbitmq-server#1729.

[#161136615]
2018-10-11 03:00:39 +03:00
Jean-Sébastien Pédron a1d729b56a Update rabbitmq-components.mk 2018-09-19 10:38:19 +02:00
Jean-Sébastien Pédron 626a9ab5d1 Update rabbitmq-components.mk 2018-09-11 14:22:34 +02:00
Luke Bakken fcce77c670 Update git-commit-msgs link 2018-08-28 16:19:03 -07:00
Diana Corbacho 4d4f490bc3 Session flag must be calculated before declaring the queue
[#159921198]
2018-08-21 12:05:29 +01:00
Jean-Sébastien Pédron dbb0713f0b Update rabbitmq-components.mk 2018-08-09 17:44:18 +02:00
Jean-Sébastien Pédron f82324006c Update rabbitmq-components.mk 2018-08-09 12:17:04 +02:00
Michael Klishin a0ff2181a1 Don't await a logger process that won't ever be started on OTP 21
Same change as in a210d82f54.

References rabbitmq/rabbitmq-server#1616.

[#157964874]
2018-07-11 22:10:41 +03:00
Jean-Sébastien Pédron 2cb96acdfc Makefile: Use our emqttc fork, at least temporarily
gen_logger, a dependency of emqttc, requires large changes to work with
Erlang 21. Its use in emqttc would need to change as well.

As we are only using this client for testing purpose, it's easier for
now to remove logging completely to gain Erlang 21 compatibility.

[#157964874]
2018-06-07 11:45:02 +02:00
Michael Klishin 12cb0886d8 Compile Erlang/OTP 21
OTP 21 deprecated erlang:get_stacktrace/0 in favor of a new
try/catch syntax. Unfortunately that's not realistic for projects
that support multiple Erlang versions (like us) until OTP 21 can be
the minimum version requirement. In order to compile we have to ignore
the warning. The broad compiler option seems to be the most common
way to support compilation on multiple OTP versions with warnings_as_errors.

[#157964874]
2018-06-07 11:45:02 +02:00
Jean-Sébastien Pédron b770e48268 Update rabbitmq-components.mk 2018-06-07 11:31:39 +02:00
Jean-Sébastien Pédron 06ed90911e Update erlang.mk 2018-04-11 10:53:42 +02:00
Jean-Sébastien Pédron 23d5b49b6a Update rabbitmq-components.mk 2018-04-11 10:51:25 +02:00
Jean-Sébastien Pédron 51c0177da0 Update rabbitmq-components.mk 2018-04-11 10:10:07 +02:00
Jean-Sébastien Pédron dc7734ca9c Travis CI: Update config from rabbitmq-common 2018-04-10 13:08:25 +02:00
Jean-Sébastien Pédron 24da2b307a Makefile: Do not hard-code the supposed name of GNU Make's executable
There is the `$(MAKE)` variable populated with the current/appropriate
Make executable.
2018-04-05 10:30:46 +02:00
Jean-Sébastien Pédron 1111210ce8 Update erlang.mk 2018-03-02 19:07:39 +01:00
Jean-Sébastien Pédron ef9c188caf Update rabbitmq-components.mk 2018-01-30 15:23:47 +01:00
Luke Bakken 2f26b97e1d Update rabbitmq-components.mk 2018-01-29 16:22:18 -08:00
Jean-Sébastien Pédron 7dd2760858 Update rabbitmq-components.mk 2018-01-23 17:21:37 +01:00
Jean-Sébastien Pédron 4493123923 Update rabbitmq-components.mk 2018-01-23 15:31:25 +01:00
Diana Corbacho baf70acb32 Update rabbitmq-components.mk 2018-01-22 22:13:26 +00:00
Jean-Sébastien Pédron 8c77612a94 Merge branch 'rabbitmq-management-528' 2018-01-03 10:51:14 +01:00
Michael Klishin 729d778d88 Ignore debug/* 2018-01-03 03:30:01 +08:00
Michael Klishin 1c3c2af838 Support maps as well as proplists when fetching global runtime params
Part of rabbitmq/rabbitmq-management#528.
2018-01-03 03:29:24 +08:00
Jean-Sébastien Pédron d100c7f402 Travis CI: Update config from rabbitmq-common 2017-12-15 15:13:35 +01:00
Jean-Sébastien Pédron 8997e867bd Travis CI: Update config from rabbitmq-common 2017-12-15 14:54:57 +01:00
Jean-Sébastien Pédron b514c30401 Merge branch 'read-cert-name-from-cert-part2' into v3.7.x 2017-12-15 12:12:43 +01:00
Jean-Sébastien Pédron 665abcdf2c Merge branch 'read-cert-name-from-cert-part2' 2017-12-15 12:06:13 +01:00
Jean-Sébastien Pédron be27eea7ac java_SUITE_data: Ignore target/ 2017-12-15 12:05:24 +01:00
Jean-Sébastien Pédron 2993a1426b java_SUITE: Get certificate name from the certificate itself
... instead of hard-coding the value. This fixes the testsuite when the
generated certificate configuration changes.

The same change was made to auth_SUITE in commit a11e96caa0.

[#153697697]
2017-12-15 12:02:36 +01:00
Jean-Sébastien Pédron b316731694 Merge branch 'read-cert-name-from-cert' into v3.7.x 2017-12-15 11:42:08 +01:00
Jean-Sébastien Pédron ac32092fc2 Merge branch 'read-cert-name-from-cert' 2017-12-15 11:27:29 +01:00
Jean-Sébastien Pédron a11e96caa0 auth_SUITE: Get certificate name from the certificate itself
... instead of hard-coding the value. This fixes the testsuite when the
generated certificate configuration changes.

[#153697697]
2017-12-15 11:22:01 +01:00
Jean-Sébastien Pédron 6372727eb5 Travis CI: Update config from rabbitmq-common 2017-12-14 17:03:02 +01:00
Jean-Sébastien Pédron a353aa39df Update rabbitmq-components.mk 2017-12-14 14:38:51 +01:00
Luke Bakken 4e798ff793 Fix tests broken by rabbitmq/rabbitmq_ct_helpers#17
(cherry picked from commit 40bb49c6537faa6a45535916ee0fa69f9f0d4f14)
2017-12-08 07:02:24 -08:00
Luke Bakken 60dfb72800 Fix tests broken by rabbitmq/rabbitmq_ct_helpers#17 2017-12-07 15:36:14 -08:00
Jean-Sébastien Pédron 25b9a16cc6 Update rabbitmq-components.mk 2017-12-01 17:11:31 +01:00
Jean-Sébastien Pédron 808507d33e Update rabbitmq-components.mk 2017-12-01 15:16:37 +01:00
Jean-Sébastien Pédron bf33d6bbb2 Update rabbitmq-components.mk 2017-12-01 11:06:46 +01:00
Jean-Sébastien Pédron fdb3b5b42b Update rabbitmq-components.mk 2017-11-28 14:01:03 +01:00
Jean-Sébastien Pédron a3bc0317d2 Update rabbitmq-components.mk 2017-11-28 13:29:23 +01:00
Bernhard Schwarz 1c8831de95 Replace broken link with correct Markdown 2017-11-17 19:37:13 +00:00
Bernhard Schwarz de6c929ca8 Replace broken link with correct Markdown 2017-11-17 18:30:08 +01:00
Michael Klishin 2ebff17ddc Merge branch 'stable'
Conflicts:
	src/rabbit_mqtt_processor.erl
2017-11-09 14:23:46 +03:00
Michael Klishin a43c001779 Merge branch 'stable' into gh-132 2017-11-09 13:10:49 +03:00
Jean-Sébastien Pédron 53225ba35e Travis CI: Skip testsuite with Erlang R16B03
The emqttc client we use to test the plugin doesn't compile on Erlang
R16B03.

[#152509619]
2017-11-09 09:01:26 +01:00
Luke Bakken 717730b275 Ensure maximum message id value is used when saving to process state
Fixes #132
2017-11-08 17:31:09 -08:00
Jean-Sébastien Pédron a60881654a Travis CI: Update config from rabbitmq-common 2017-11-08 10:21:34 +01:00
Jean-Sébastien Pédron 0b38c1c018 Merge branch 'stable' 2017-11-08 10:20:32 +01:00