emqx / emqx-bridge-mqtt

Bridge of MQTT (deprecated since EMQX v5)
https://www.emqx.com
Apache License 2.0
37 stars 13 forks source link

Bridge stops working after sending a message #79

Closed fuegas closed 4 years ago

fuegas commented 4 years ago

Hi!

We're using a bridge between two clusters (both running EMQX 4.0.7) to forward messages. However, when it sends a message the bridge stops working and raises the following error:

(emqx@172.31.164.18)1> 2020-06-22 12:51:50.211 [info] [Bridge] Bridge emqx_bridge_worker_NAME diconnected
reason={puback_error_code,16}
(emqx@172.31.164.18)1> 2020-06-22 12:51:50.211 [error] ** State machine <0.1983.0> terminating
** Last event = {cast,{mqtt_packet,{mqtt_packet_header,4,false,0,false},
                                   {mqtt_packet_puback,2,16,#{}},
                                   undefined}}

So, the reason given is: {puback_error_code,16}. When we take a look at the source code handling the puback:

handle_puback(Parent, #{packet_id := PktId, reason_code := RC}) ->
    RC =:= ?RC_SUCCESS orelse error({puback_error_code, RC}),
    Parent ! {batch_ack, PktId},
    ok.

It matches RC to RC_SUCCESS and must match type. In this project RC_SUCCESS is not defined, however it is defined in emqx itself:

-define(RC_SUCCESS,                                16#00).
...
-define(RC_NO_MATCHING_SUBSCRIBERS,                16#10).

From the error code we receive a RC_NO_MATCHING_SUBSCRIBERS. My question is: should this close the bridge connection and stop the bridge from functioning at all?

The situation we're in now is that we receive this error and the bridge is disconnected each time we try to start the bridge. How can we resolve this issue?

fuegas commented 4 years ago

Closing this issue in favor of issue at main repository: emqx/emqx#3553.