Pubsubclient: Connecting MQTT broker over websockets using SSL

Created on 17 Feb 2018  路  5Comments  路  Source: knolleary/pubsubclient

Hi @knolleary

I have a MQTT broker running over websockets using SSL on my server.
Would like my ESP2866 client to connect to this broker.

Will you please help me in sample code to implement it.

Thanks.

Most helpful comment

You may have a look into (if speaking of ESP chip based implementation).

https://github.com/me-no-dev/ESPAsyncTCP
https://github.com/marvinroger/async-mqtt-client

Good luck ;)

All 5 comments

Hi. This library doesn't support websockets. Sorry.

Hi @knolleary

Thanks for your quick reply.
So is there any workaround to implement secured MQTT client?
Any other alternative ?

Thanks.

You may have a look into (if speaking of ESP chip based implementation).

https://github.com/me-no-dev/ESPAsyncTCP
https://github.com/marvinroger/async-mqtt-client

Good luck ;)

FOR ESP8266 :
I'm using areve https://github.com/areve/WebSocketStreamClient :+1:

2 lignes of code and you're using PubSubClient over WS (WSS SUPPORTED)
without any modification on PubSubClient lib itself
:))))

example code :

WiFiClientSecure wiFiClient;
WebSocketClient wsClient(wiFiClient, host, port);
WebSocketStreamClient wsStreamClient(wsClient, path);
PubSubClient mqtt(wsStreamClient);
....
mqtt.setCallback(onMqttPublish);
mqtt.connect("xxxxx")

You can also have a look to my own repo for version compatible with last Arduino version

@knolleary : perhaps the idea of implementing ws through client.h with arduinohttpclient (or other) could be an "official" way to support ws...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

himanshu-hearthacker picture himanshu-hearthacker  路  8Comments

mr2c12 picture mr2c12  路  9Comments

i17brn picture i17brn  路  9Comments

HobbytronicsPK picture HobbytronicsPK  路  4Comments

winterzh picture winterzh  路  10Comments