|
Re: MQTT over Websockets - status code 302 redirect ? [message #1855967 is a reply to message #1855906] |
Sat, 12 November 2022 17:09 |
Bojan Pogacar Messages: 2 Registered: November 2022 |
Junior Member |
|
|
Hi!
I've been doing some tests and I can't get redirects to work.
My section of the code is as follows:
mqttc = mqtt.Client(client_id="pythonclient", transport='websockets')
mqttc.ws_set_options(path="/ws")
mqttc.on_message = on_message
mqttc.on_connect = on_connect
mqttc.on_publish = on_publish
mqttc.on_subscribe = on_subscribe
mqttc.connect("127.0.0.1", 8888, 60)
When on IP 127.0.0.1, port 8888 is listening mosquitto mqtt websocket server, everythink is working fine.
WHhen on IP 127.0.0.1, port 8888 is listening some other webserver (nginx for exxample) , which does HTTP redirect like this (yes, mqtt websockets are exposed this time on port 9001)
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Location: ws://localhost:9001/ws
Date: Sat, 12 Nov 2022 17:04:16 GMT
I get an error:
raise WebsocketConnectionError("WebSocket handshake error")
paho.mqtt.client.WebsocketConnectionError: WebSocket handshake error
---------------
My conclusion is, that paho mqtt client does not follow HTTP 30x redirects, which should by the RFC6455 written below or I don't know how to instruct it to follow redirects.
Can you please help me with that.
============================
RFC 6455 The WebSocket Protocol December 2011
1. If the status code received from the server is not 101, the
client handles the response per HTTP [RFC2616] procedures. In
particular, the client might perform authentication if it
receives a 401 status code; the server might redirect the client
using a 3xx status code (but clients are not required to follow
them), etc. Otherwise, proceed as follows.
[Updated on: Sat, 12 November 2022 17:12] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03098 seconds