arduino-libraries / ArduinoHttpClient

Arduino HTTP Client library
288 stars 171 forks source link

Websocket Client to wss #117

Open toJuanito opened 3 years ago

toJuanito commented 3 years ago

Hi, is it possible to communicate through wss protocol? It works fine for me with ws.

#include <ArduinoJson.h>
#include <HttpClient.h>
#include <SoftwareSerial.h>
#include <Ethernet.h>
#include <WebSocketClient.h>

EthernetClient ethernet;

#include <ArduinoHttpClient.h>
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};

char serverAddress[] = "wss://192.168.1.87";  //I dont know if it is possible, seems like not..
int port = 8010;

WebSocketClient client = WebSocketClient(ethernet, serverAddress, port);

Thanks in advance..

clysss commented 2 years ago

Perhaps I've not correctly understood the question... with this following code, I connect with mqttServer="xxx.azurewebsites.net" on port 443... (wss)

WiFiClientSecure wifiClient;
WebSocketClient wsClient(wifiClient, mqttServer, 443);
WebSocketStreamClient wsStreamClient(wsClient, mqttPath);
PubSubClient MQTTClient(wsStreamClient);

you should have a look to https://github.com/clysss/WebSocketStreamClient and https://github.com/arduino-libraries/ArduinoHttpClient/pull/124