Git Product home page Git Product logo

Comments (3)

frankiboy1 avatar frankiboy1 commented on August 29, 2024

Seems like there is one issue, which I have not found a resolution for, but you might be able to understand this.

With the above patch, I can successfully connect to my broker using mqtts and client certificates. homebridge-mqtt publish several messages and subscribe to some topics. Then it disconnects and reconnects every few seconds. There's no extra output from homebridge, so it looks like the homebridge-mqtt is unaware that the client is disconnecting.

From the logs it looks like the client tries to connect a second time, which causes the disconnect.

I've tried both mosquitto v1.4.8 and mosquitto v1.4.11 with the same result.

1494113633: mosquitto version 1.4.11 (build date Mon, 20 Feb 2017 22:47:27 +0000) starting
1494113633: Config loaded from /etc/mosquitto/mosquitto.conf.
1494113633: Opening ipv4 listen socket on port 8883.
1494113633: Opening ipv6 listen socket on port 8883.
1494113634: New connection from 10.1.50.120 on port 8883.
1494113634: New client connected from 10.1.50.120 as mqttjs_470dec79 (c1, k60, u'username').
1494113634: Sending CONNACK to mqttjs_470dec79 (0, 0)
1494113634: Received SUBSCRIBE from mqttjs_470dec79
1494113634: homebridge/to/# (QoS 0)
1494113634: mqttjs_470dec79 0 homebridge/to/#
1494113634: Sending SUBACK to mqttjs_470dec79
1494113634: Received SUBSCRIBE from mqttjs_470dec79
1494113634: homebridge/to/# (QoS 0)
1494113634: mqttjs_470dec79 0 homebridge/to/#
1494113634: Sending SUBACK to mqttjs_470dec79
1494113634: Received SUBSCRIBE from mqttjs_470dec79
1494113634: homebridge/to/# (QoS 0)
1494113634: mqttjs_470dec79 0 homebridge/to/#
1494113634: Sending SUBACK to mqttjs_470dec79
1494113634: Received SUBSCRIBE from mqttjs_470dec79
1494113634: homebridge/to/# (QoS 0)
1494113634: mqttjs_470dec79 0 homebridge/to/#
1494113634: Sending SUBACK to mqttjs_470dec79
1494113634: Received SUBSCRIBE from mqttjs_470dec79
1494113634: homebridge/to/# (QoS 0)
1494113634: mqttjs_470dec79 0 homebridge/to/#
1494113634: Sending SUBACK to mqttjs_470dec79
1494113634: Received PUBLISH from mqttjs_470dec79 (d0, q0, r0, m0, 'homebridge/from/connected', ... (30 bytes))
1494113634: New connection from 10.1.50.33 on port 8883.
1494113634: Sending CONNACK to 10.1.50.33 (0, 5)
1494113634: Socket error on client , disconnecting.
1494113635: New connection from 10.1.50.33 on port 8883.
1494113635: Sending CONNACK to 10.1.50.33 (0, 5)
1494113635: Socket error on client , disconnecting.

from homebridge-mqtt.

frankiboy1 avatar frankiboy1 commented on August 29, 2024

Doing some further debugging on my patch, I found that the disconnects happens because another python client is misbehaving. Disabling the python client makes everything work as expected.

from homebridge-mqtt.

frankiboy1 avatar frankiboy1 commented on August 29, 2024

And to close this from my side....

You need to pass the options when connecting anonymously as well, to enable certificates with anonymous connections. (This is probably very relevant as the username/password is likely to be dropped when you authenticate with certificates).

It looks like these lines could be simplified to allow this:

if(options.username === null || options.password === null) {
this.log("connect Anonymous");
client = mqtt.connect(url);
} else {
this.log("connect Authentication with username/password");
client = mqtt.connect(url, options);
}

Changing the above lines to:

this.log("connecting");
client = mqtt.connect(url, options);

Would work for both anonymous connections and when using username/password.

from homebridge-mqtt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.