mycontroller-org / server

MyController 2.x server
https://mycontroller.org
Apache License 2.0
35 stars 9 forks source link

Gateway mqtt : "error on subscription:connection lost before" #21

Closed Yourry closed 9 months ago

Yourry commented 10 months ago

Good morning, I recently restarted MyController and I have this error coming back:

Connected successfully, error on subscription:connection lost before Subscribe completed

Connected successfully, error on subscription: connection lost before Subscribe completed Once the error is present, only a stop and start of the service restarts operation until the next error... I don't really understand, I tried to change the registration/publication topics a little but nothing works. Note that I am with a Sensebender Gateway + ethernet shield + mqtt

My config:

id: Gateway_MySensors_MQTT description: '' enabled: true reconnectDelay: 30s queueFailedMessage: false provider: protocol: broker: 192.168.1.12:1883 insecure: false password: >- ENCRYPTED;MC;AES256;BASE64;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX publish: mygateway1-in/# qos: 0 subscribe: mygateway1-out/# transmitPreDelay: 10ms type: mqtt username: xxxxxxxxxxxx retryCount: 3 timeout: 500ms type: mysensors_v2 messageLogger: type: none labels: location: server others: {} state: status: up message: >- Connected successfully, error on subscription:connection lost before Subscribe completed since: '2024-02-03T15:43:29.071824793+01:00' modifiedOn: '0001-01-01T00:00:00Z' lastTransaction: '0001-01-01T00:00:00Z'

And log :

mycontroller_1.log

If you have an idea, I'm interested. Thank you so much

Yourry commented 10 months ago

I just tested by increasing the Timeout in the "Provider" section and it seems to work. I went from 500ms to 2000ms. To see if it works well over a period of one day

Yourry commented 9 months ago

Ultimately false hope: image

jkandasa commented 9 months ago

@Yourry the publish topic should not contain #, it should be as mygateway1-in but for this issue, that's not a root cause can you restart your MQTT broker(192.168.1.12:1883) once? Also check the MQTT broker log file

Yourry commented 9 months ago

Thanks for your help,

I removed the #, to have:

publish: mygateway1-in subscribe: mygateway1-out

Unfortunately this doesn't seem to work. Mosquitto side, not much in the logs:

1707342615: New connection from 192.168.1.109 on port 1883. 1707342615: New client connected from 192.168.1.109 as Gateway_MySensors_MQTT-vn6zq (c0, k30, u'MyControllerWeb'). 1707342615: Socket error on client Gateway_MySensors_MQTT-vn6zq, disconnecting. 1707342719: New connection from 192.168.1.109 on port 1883.

jkandasa commented 9 months ago

@Yourry you have to remove the # from publish. on the subscribe you should have # example:

Have you restarted your mosquitto broker? I see this error leads the failure: 1707342615: Socket error on client Gateway_MySensors_MQTT-vn6zq, disconnecting. What is the version of your mosquitto? I do give a try locally.

Yourry commented 9 months ago

Ok, I made the changes as requested in the publish and subscribe commands. I stopped mosquitto and MyController after i then started mosquitto and started MyController. For the moment it seems to work well but I think we need to wait a little. My version of mosquitto is:

mosquitto version 1.5.7 mosquitto is an MQTT v3.1.1 broker.

jkandasa commented 9 months ago

@Yourry thanks for the details Minimum mosquitto tested version is 1.6.9 Can you upgrade your mosquitto broker to 1.6.9 or above?

https://mycontroller.org/docs/getting-started/install-mosquitto/

Yourry commented 9 months ago

I just saw that my version of Mosquitto is a little old :) For the moment with the right topics it works well. I can't really upgrade to the new versions of mosquitto at the moment, it is not available on the version of debian 10 that I am using. In the near future, I will install Mosquitto on another machine with debian 12 but it requires a bit of work because I need to update my nodes. In any case, thank you very much for your help!

Yourry commented 9 months ago

Really thank you very much for your help and work!!!