-
Notifications
You must be signed in to change notification settings - Fork 42
Description
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 SUBSCRIBEPresumbly, 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.