Search code examples
socketsmqttmosquittobroker

Socket error on client <clientid>, disconnecting


I am running a mosquitto broker and there are two nodes interacting. One is an android application and the other one is a node application. Everything runs fine in local but when I host it on the server with different IP addresses, the broker disconnects the android with an error message stating "Socket error..." The communication is WebSocket.

Not a firewall issue, edited the rules to include the port

1563531509: New client connected from 115.110.139.126 as mqttjs_8eceda19 (p2, c1, k60).
1563531509: No will message specified.
1563531509: Sending CONNACK to mqttjs_8eceda19 (0, 0)
1563531522: Received PUBLISH from mqttjs_8eceda19 (d0, q2, r0, m56220, 'navigation', ... (66 bytes))
1563531522: Sending PUBREC to mqttjs_8eceda19 (m56220, rc0)
1563531522: Received PUBREL from mqttjs_8eceda19 (Mid: 56220)
1563531522: Sending PUBLISH to RepositoryClient (d0, q1, r0, m1, 'navigation', ... (66 bytes))
1563531522: Sending PUBCOMP to mqttjs_8eceda19 (m56220)
1563531522: New client connected from 115.110.139.126 as mqttjs_98f933df (p2, c1, k60).
1563531522: No will message specified.
1563531522: Sending CONNACK to mqttjs_98f933df (0, 0)
1563531522: Socket error on client RepositoryClient, disconnecting.
1563531522: Received SUBSCRIBE from mqttjs_98f933df
1563531522:     test (QoS 2)
1563531522: mqttjs_98f933df 2 test
1563531522: Sending SUBACK to mqttjs_98f933df
1563531524: New client connected from 115.110.139.126 as RepositoryClient (p2, c0, k6464).
1563531524: No will message specified.
1563531524: Sending CONNACK to RepositoryClient (1, 0)
1563531524: Sending PUBLISH to RepositoryClient (d1, q1, r0, m1, 'navigation', ... (66 bytes))
1563531524: Socket error on client RepositoryClient, disconnecting.

Solution

  • Apparently there was an exception thrown by client during subscription and the client was trying to reconnect with the same id. Hence the socket error. Fixing the cause of exception fixed the issue.