patchwork-toolkit / patchwork

Lightweight Platform for the Network of Things
http://patchwork-toolkit.github.io
MIT License
57 stars 6 forks source link

Add a dynamic part to the MQTT clientId #30

Closed krylovsk closed 9 years ago

krylovsk commented 10 years ago

The mqtt library disconnects when a client with the same clientID connects to the broker

oleksandr commented 10 years ago

Otherwise the DGW goes into infinite loop trying to connect to a broker. Need to handle this in a clever way: allow several attempts and then sleep for some TTL, then try again (avoid discotheque in the terminal)

krylovsk commented 10 years ago

The problem is not in connecting to the server - it is that immediately after connecting it gets disconnected (the clientID problem). There is already a back-off on establishing a connection.

oleksandr commented 10 years ago

Good! But it does not help to avoid loop over:

[device-gateway] 10:26:24 MQTTPulbisher: lost connection to the broker: EOF [device-gateway] 10:26:24 MQTTPublisher: connecting to the broker tcp://127.0.0.1:1883, backOff: 0 sec [device-gateway] 10:26:24 MQTTPublisher: connected to the broker tcp://127.0.0.1:1883 [device-gateway] 10:26:24 MQTTPulbisher: lost connection to the broker: EOF [device-gateway] 10:26:24 MQTTPublisher: connecting to the broker tcp://127.0.0.1:1883, backOff: 0 sec