Page 1 of 1

Socket.io (Websocket) Client Example

Posted: Mon Jun 05, 2017 6:54 am
by nwgarner
Hello Everyone,
Are there any examples for connecting to a websocket server from ESP-32 IDF? There's numerous examples of running a websocket server on the ESP-32, just can't seem to find the inverse.

Thank you,
Nick

Re: Socket.io (Websocket) Client Example

Posted: Wed Jun 07, 2017 3:31 pm
by Scalpel78
I'm really interrested in this as well!

Re: Socket.io (Websocket) Client Example

Posted: Wed Jun 07, 2017 3:41 pm
by kolban
Imagine the question was being asked in a "Linux" environment. What libraries/tools/technologies would you consider to be the one(s) you would want to use? If we (community) can find an API on Linux, then we can perhaps undertake a task to attempt the goal in the ESP32 environment.

What sub platforms of ESP32 would be desired to be supported?

* ESP-IDF
* C++ using ESP-IDF
* C++ using Arduino
* Other languages ...

Re: Socket.io (Websocket) Client Example

Posted: Wed Jun 07, 2017 3:47 pm
by Scalpel78
Socket.io actually has a C++ client example here:

https://github.com/socketio/socket.io-client-cpp

Perhaps it can work on ESP32?

Re: Socket.io (Websocket) Client Example

Posted: Thu Jun 08, 2017 4:27 am
by kolban
I was looking through some docs on Mongoose networking. This is a library which is known to work fine with ESP32 ESP-IDF. Reading the docs, it seems to have outbound WS support. See:

https://docs.cesanta.com/mongoose/maste ... ect_ws.md/

Re: Socket.io (Websocket) Client Example

Posted: Fri Jun 09, 2017 11:46 am
by kurtzweber
Hi

just note that websocket and socket.io are different things... you cannot connect to a socket.io server using a "generic" websocket client:

https://en.wikipedia.org/wiki/Socket.IO

so if your goal is to implement a connection from ESP32 to a Socket.IO server you have to implement the full "socket.io" protocol... some clients (including a C++ and java implementation) are available in the official repo:
https://github.com/socketio

Re: Socket.io (Websocket) Client Example

Posted: Sun Sep 10, 2023 6:00 pm
by cjohnweb
I am actually looking for something similar: I need a socket.io-server in cpp for the ESP32.

I wrote an automation controller in NodeJS using Socket.IO. Kind of a large project, with multiple other clients already written in JavaScript. The thing is, though, the system expects the ESP32 to have its own socket.io server, and the nodejs server connects to it as the client. In this way, the ESP chip becomes a very flexible open-source device with less configuration requirements that may support multiple programming projects by providing its own socket server.

Unfortunately, all I can find online is a socket.io-client, and a number of other websocket implementations that do not natively work with socket.io.

Does anyone have any ideas or recommendations? Right now, I am thinking the solution is to find a supported websocket-client on the ESP32, and build an alternative client implementation on the nodejs side specifically for devices that do not support socket.io. It's a big pain in the ***, as a socket.io server should not be that complex to implement a basic light-weight version, especially considering the dual-core 240Mhz processor of the ESP32.

Thanks