我正在运行一个 mosquitto 代理,并且有两个节点在交互。一个是安卓应用程序,另一个是节点应用程序。在本地一切正常,但是当我使用不同的IP地址将其托管在服务器上时,代理会断开android的连接,并显示一条错误消息,指出"套接字错误..."通信是WebSocket。
不是防火墙问题,编辑规则以包含端口
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.
显然,
客户端在订阅期间抛出了异常,客户端正在尝试使用相同的 ID 重新连接。 因此套接字错误。修复异常原因解决了该问题。