I am creating home automation using esp's and little home server. Idea is to connect arduinos to server, add each of them id and let them talk via websockets with server and server will forward (by some logic inside) messages to different arduinos. Pretty simple.

What I found, is that I cannot tell, what websocket client I am talking to. I use simple example from lib: https://github.com/gilmaimon/ArduinoWebsockets

client.connect(websockets_server_host, websockets_server_port, "/");

My idea is to send id of arduino with connection handshake. Is it even possible?

  • This is a websocket client code. The client is not talking to other clients, but the server. He doesn't need to differentiate clients.
    – Sim Son
    Commented Dec 7, 2021 at 18:33
  • Exactly. Server will forward messages from one client to antoher. Problem is, that on server side I have multiple clients, that I cannot distinguish so I need each client to identify itself when it connect
    – 110mat110
    Commented Dec 7, 2021 at 19:16
  • You can even add your device id with every message you send to the server.
    – Fahad
    Commented Dec 7, 2021 at 22:19
  • I like to pass a an identifying GET param in the websocket URL (eg. system_get_chip_id()), then the PC-based server socket lib has a (sometimes roundabout) way of getting the request URL to id who's asking.
    – dandavis
    Commented Dec 8, 2021 at 18:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.