eclipse / mosquitto.rsmb

Mosquitto rsmb
82 stars 42 forks source link

Errors after MQTT-SN client reconnection #3

Open ralight opened 8 years ago

ralight commented 8 years ago

migrated from Bugzilla #462795 status UNCONFIRMED severity major in component RSMB for 1.4 Reported in version unspecified on platform PC Assigned to: Ian Craggs

On 2015-03-22 14:07:00 -0400, Ivan Makeev wrote:

When MQTT-SN client reconnects with same client ID, it gets "transport endpoint not connected" error on any packet sent after CONNECT. Example from RSMB log:

20150322 185455.213 CWNAN0034I Duplicate connection attempt received for client identifier "ENV-02124B00040EF660" from address 127.0.0.1:54113, ending oldest connection 20150322 185455.213 134517200 127.0.0.1:54113 ENV-02124B00040EF660 -> MQTT-S CONNACK returncode 0 (0) 20150322 185455.213 CWNAN0000I Client connected to udp port 1882 from ENV-02124B00040EF660 (127.0.0.1:54113) 20150322 185510.128 CWNAN0075W Socket error 107 (Transport endpoint is not connected) in getpeername for socket 3 20150322 185510.128 CWNAN0023W Connect was not first packet on socket 3, peer address unknown; got SUBSCRIBE

Presumbly, the error caused by not updating the clients table properly. In MQTTSProtocol.c, function MQTTSProtocol_handleConnects contains block for such a case under /* have to remove and re-add client so it is in the right order for new socket */ but condition (client->socket != sock) will always evaluate to false as statement client->socket = sock; goes few lines before. Seems full address should be compared here before new socket value is assigned. Moreover, inside this block the statement: TreeRemoveKeyIndex(bstate->mqtts_clients, &client->socket, 0); should be presumably changed to TreeRemoveKeyIndex(bstate->mqtts_clients, client->addr, 0); as index in the tree is over full address, not just socket.

elAlexOm commented 8 years ago

День добрый, Иван. Нашли-ли Вы решение этой проблемы ? Алексей.

njh commented 8 years ago

Translated:

Good morning , Ivan . Found - if you solve this problem ? Alexey.

Note that since this issue was migrated from Bugzilla, it is unlikely that Ivan is receiving notifications about this issue.

elAlexOm commented 8 years ago

Thank you.

aguegu commented 6 years ago

This bug is quite annoying.

How to refresh the client list? It seems that even if I restart the broker, the old connection cache is still there and affecting new connections.