Socket.io (Websocket) Client Example

nwgarner
Posts: 3
Joined: Mon Jun 05, 2017 6:47 am

Socket.io (Websocket) Client Example

Postby nwgarner » Mon Jun 05, 2017 6:54 am

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

Scalpel78
Posts: 51
Joined: Sun Feb 26, 2017 7:31 am

Re: Socket.io (Websocket) Client Example

Postby Scalpel78 » Wed Jun 07, 2017 3:31 pm

I'm really interrested in this as well!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Socket.io (Websocket) Client Example

Postby kolban » Wed Jun 07, 2017 3:41 pm

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 ...
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Scalpel78
Posts: 51
Joined: Sun Feb 26, 2017 7:31 am

Re: Socket.io (Websocket) Client Example

Postby Scalpel78 » Wed Jun 07, 2017 3:47 pm

Socket.io actually has a C++ client example here:

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

Perhaps it can work on ESP32?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Socket.io (Websocket) Client Example

Postby kolban » Thu Jun 08, 2017 4:27 am

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/
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

kurtzweber
Posts: 64
Joined: Tue Jan 10, 2017 1:09 pm

Re: Socket.io (Websocket) Client Example

Postby kurtzweber » Fri Jun 09, 2017 11:46 am

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

cjohnweb
Posts: 1
Joined: Sun Sep 10, 2023 5:51 pm

Re: Socket.io (Websocket) Client Example

Postby cjohnweb » Sun Sep 10, 2023 6:00 pm

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

Who is online

Users browsing this forum: No registered users and 175 guests