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.
This gives a greater chance to the Last Will message to be delivered
because it will implicitely block `rabbit_mqtt_reader` while the
server-side AMQP channel processes the message.
Without this, `rabbit_mqtt_reader` asks the Last Will message to be
sent asynchronously and immediately closes the AMQP connection. The
server-side AMQP channel might thus try to query an already closed
connection.
Fixes#146.
[#150162950]
(cherry picked from commit a2eb8c1be8c52d476ee9ea0ff08ef381a2ca326c)
This gives a greater chance to the Last Will message to be delivered
because it will implicitely block `rabbit_mqtt_reader` while the
server-side AMQP channel processes the message.
Without this, `rabbit_mqtt_reader` asks the Last Will message to be
sent asynchronously and immediately closes the AMQP connection. The
server-side AMQP channel might thus try to query an already closed
connection.
Fixes#146.
[#150162950]
Lager sink parse-transform allows us to use a fake module name
to select sinks.
It's more convenient that to use a helper function for every module.
[#149634975]
Plugin handles exit signal coming from the AMPQ core,
logs, and closes the client connnection (instead of letting
the whole process tree crash with scary log messages).
References rabbitmq/rabbitmq-server#505
check_resource_access used to be called with
the MQTT topic as resource name and kind = topic.
It makes more sense now to call check_topic_access
with the exchange as resource name, kind = topic,
and routing key in the context.
References rabbitmq/rabbitmq-server#505
Return CONNACK 4 code when the virtual host doesn't exist.
The MQTT description for this return code states "The data in
the user name or password is malformed", which not exactly
accurate but better than a pending or abruptly closed connection.
The server logs also a more meaningful message.
Fixes#100