Links2004 / arduinoWebSockets

arduinoWebSockets
GNU Lesser General Public License v2.1
1.89k stars 555 forks source link

Unable to connect esp8266 via https to socket.io; error 400 #675

Closed KrzysztofMoskalik closed 3 years ago

KrzysztofMoskalik commented 3 years ago

Hi,

I'm trying connect NodeMCU v3 (esp8266) to socket.io server via https. I'm using Arduino IDE (latest version) and latest version of this lib. Using code from example WebSocketClientSocketIO i cannot connect to server.

Socket.io server i'm using is nodeJs socket.io-server (2.3.1) which is running behind nginx proxy and this proxy is throwing me http error 400. I'm confused, because simple nodeJs client is working for this server:

const io = require("socket.io-client");

const socket = io('https://my-example-host.com', { transports: ["websocket"] });

I've tried both socketIO.begin(socketHost, 443, "/socket.io/?EIO=3&transport=websocket"); and socketIO.beginSSL(socketHost, 443, "/socket.io/?EIO=3&transport=websocket");

also for socketHost i've tried my-example-host.com and https://my-example-host.com.

KrzysztofMoskalik commented 3 years ago

After upgrading to V4 both server and "/socket.io/?EIO=4" all started work properly.

hoangmanhh99 commented 2 years ago

@KrzysztofMoskalik can I see your code? I have same issue but can not resolve