Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Constant disconnect because of Connection refused - incorrect protocol version(paho client for a Broadlink MP1 device won't connect to MQTT broker)
Constant disconnect because of Connection refused - incorrect protocol version [message #1780133] Wed, 17 January 2018 20:21 Go to next message
Mir Quintilianus is currently offline Mir QuintilianusFriend
Messages: 8
Registered: December 2017
Junior Member
Hello everybody,

I am using the python Paho client library along with a python client config reader and a python module for controlling Broadlink MP1 device.

https://github.com/mjg59/python-broadlink
https://github.com/eschava/broadlink-mqtt

These two, they seem to work OK since the Broadlink device is discovered.
However, when the client finally tries to connect to the MQTT broker, it keeps getting disconnected, reportedly because of an incorrect protocol version.
The MQTT broker is an ActiveMQ Artemis broker, which is part of an Eclipse Kura emulator set up on a Debian 9 machine.
I have tested the broker with mqtt-spy and it's up and running.
I have been trying quite a few things before posting this, but still no result whatsoever.
Below are the logs with as much info as I managed to get from the logger.
Already tried changing the protocol version between 3.1 and 3.1.1, and also tried setting back and forth the clean_session flag.

Any idea why I still keep getting this code 1: Connection refused - incorrect protocol version?
Anything is welcome!

[2018-01-14 16:35:44,012] DEBUG Connected to MP1 Broadlink device at ('192.168.1.151', 80)
[2018-01-14 16:35:44,012] DEBUG Protocol version is 4
[2018-01-14 16:37:31,194] DEBUG Connected to MP1 Broadlink device at ('192.168.1.151', 80)
[2018-01-14 16:37:31,195] DEBUG Protocol version is 4
[2018-01-14 16:37:31,196] DEBUG Sending CONNECT (u1, p1, wr0, wq0, wf1, c0, k60) client_id=broadlink_test_client
[2018-01-14 16:37:31,198] DEBUG Calling from main right after mqttc.connect()
[2018-01-14 16:37:31,200] DEBUG OOOOPS! Broadlink disconnects
[2018-01-14 16:37:31,201] DEBUG CONNACK received by on_disconnect with code: 1
[2018-01-14 16:37:42,211] DEBUG Sending CONNECT (u1, p1, wr0, wq0, wf1, c0, k60) client_id=broadlink_test_client
[2018-01-14 16:37:42,213] DEBUG OOOOPS! Broadlink disconnects
[2018-01-14 16:37:42,213] DEBUG CONNACK received by on_disconnect with code: 1
Re: Constant disconnect because of Connection refused - incorrect protocol version [message #1780167 is a reply to message #1780133] Thu, 18 January 2018 10:24 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
That should be because the broker is expecting MQTT 3.1.1 or MQTT 3.1 and the client is connecting as the other even though you say you've tried it. If mqtt-spy has connected, then it seems things are fundamentally working.
Re: Constant disconnect because of Connection refused - incorrect protocol version [message #1780172 is a reply to message #1780167] Thu, 18 January 2018 11:11 Go to previous messageGo to next message
Mir Quintilianus is currently offline Mir QuintilianusFriend
Messages: 8
Registered: December 2017
Junior Member
Well, to be 100 percent accurate here's what I did when I say I tried changing between MQTT 3.1.1 and MQTT 3.1:

As you can see from the 2nd line from the debug output, it says protocol version is 4, which as far as I could gather from reading the client Code on github should stand for the 3.1.1 version. I tried to pass 3, reportedly standing for the 3.1 version, as value for the protocol parameter to the constructor for the client object and it was accepted, which I verified from the debug output (not included in the output above).
Here's the code I referred to (lines 62-63):
https://github.com/eclipse/paho.mqtt.python/blob/master/src/paho/mqtt/client.py

Do you mean that there is a chance of a mismatch between the protocol parameter ranges of the code on github and the actual Paho library I installed in Debian with "pip install paho-mqtt"?
Any advice on the correspondence between the int parameter passed to the class constructor and the protocol version?

[Updated on: Thu, 18 January 2018 14:44]

Report message to a moderator

Re: Constant disconnect because of Connection refused - incorrect protocol version [message #1780444 is a reply to message #1780167] Mon, 22 January 2018 14:17 Go to previous messageGo to next message
Mir Quintilianus is currently offline Mir QuintilianusFriend
Messages: 8
Registered: December 2017
Junior Member
Meanwhile, I did some more research on mqtt implementations. It turned out that, depending on the broker version, there might be another viable option for the protocol version parameter mentioned above. That option is 5, which according to the documentation should stand for v5.0. Unfortunately, that didn't work either. Then just for the sake of it, I decided to try passing anything between 1 and 7. Same result as before.

All this makes me think, the incorrect protocol version message I get from the debugger doesn't have much to do with the reason for the disconnect. It looks like it's just masking something else which is wrong either with the emulated Kura implementation of the ActiveMQ broker service, or with the Paho client itself, or a glitch on the very edge between them.

I would very much appreciate any feed whatsoever!
Re: Constant disconnect because of Connection refused - incorrect protocol version [message #1780786 is a reply to message #1780444] Sat, 27 January 2018 07:45 Go to previous message
Mir Quintilianus is currently offline Mir QuintilianusFriend
Messages: 8
Registered: December 2017
Junior Member
Here's what worked out in the end

https://www.eclipse.org/forums/index.php/m/1780785/
Previous Topic:Useful client tool presentation
Next Topic:How can I fetch stored messages using javascript or PHP
Goto Forum:
  


Current Time: Sat Apr 20 02:07:09 GMT 2024

Powered by FUDForum. Page generated in 0.03286 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top