areve / WebSocketStreamClient

10 stars 11 forks source link

Can't commucate with mosquitto #7

Open emsi opened 2 years ago

emsi commented 2 years ago

It took me few days to identify why WebSocketStreamClient can't communicate with mosquitto behind rev-proxy. Since I've spent way more time then I should I'm posting the solution here for other troubled souls like mine :)

After analyzing all layer of communication I've fount that the Sec-WebSocket-Protocol: mqtt header is mandatory, otherwise mosquitto is deaf to any mqtt messages over the websocket. The solution requires modification of (at least) ArduinoHttpClient (I'll open pr there and if accepted I'll open another one here).

In the meantime I've committed required changes to the following repos:

https://github.com/emsi/WebSocketStreamClient https://github.com/emsi/ArduinoHttpClient

The changes are in the commit: https://github.com/emsi/ArduinoHttpClient/commit/56772a07ab7ef5e72f5a2f6ec6a2d86b75fad65e and: https://github.com/emsi/WebSocketStreamClient/commit/aee5480f47cd5180c2b98f4e2752913906241bc7

andyli commented 1 year ago

I also need this in order to make WebSocketStreamClient connect to emqx.

Without it, WebSocketStreamClient fails to connect.