Hello,
We have an MQTT broker which we connect to it using MQTT.js client over WebSockets using port 443; all is working well, we would like to connect a different client, this time using Python paho.mqtt.client, using the same connection settings as the MQTT.js client raises an error with the Python client, this is the code I use to connect to the broker:
client = mqtt.Client('clientID-938457', transport="websockets")
client.ws_set_options(path="/mqtt", headers=None)
client.username_pw_set(username="NotMyRealToken",password="")
print(f'trying to connect.....')
client.connect("mqtt.flespi.io", 443, 60)
and the output log:
trying to connect.....
Traceback (most recent call last):
File "C:\Users\Antec\Dropbox (Personal)\Python PoC\aioHttp Server\MQTT_Flespi.py", line 48, in <module>
client.connect("mqtt.flespi.io", 443, 60)
File "C:\Users\Antec\AppData\Roaming\Python\Python37\site-packages\paho\mqtt\client.py", line 914, in connect
return self.reconnect()
File "C:\Users\Antec\AppData\Roaming\Python\Python37\site-packages\paho\mqtt\client.py", line 1081, in reconnect
self.websocket_path, self.websocket_extra_headers)
File "C:\Users\Antec\AppData\Roaming\Python\Python37\site-packages\paho\mqtt\client.py", line 3713, in init
self._do_handshake(extra_headers)
File "C:\Users\Antec\AppData\Roaming\Python\Python37\site-packages\paho\mqtt\client.py", line 3797, in _do_handshake
raise WebsocketConnectionError("WebSocket handshake error")
paho.mqtt.client.WebsocketConnectionError: WebSocket handshake error
can you pls let us know what is it we are doing wrong?
Cheers,
WT