How to connect to WebSocket as client in ESP32?
In AsyncWebSocketClient have a client connected to AsyncWebSocket. But how to connect as client in ESP32? Server.ino
void setup() {
//...
AsyncWebSocket ws("/ws");
ws.onEvent(onEvent);
server.addHandler(&ws);
//...
}
TODO
Client.ino
void setup() {
//...
AsyncWebSocketClientRequest wsc("ws://192.168.4.1:80/ws");
if (wsc.connect()) {
wsc.onData([](String data) {
});
}
//...
}
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
Any suggestion?
[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.
Hi @augustoeliezer, it doesn't work for me either. I had to use another WS client, see my code.
I know this is a rather old issue, but for future reference maybe try using ArduinoWebsockets on the client side. With a static ip on the server side you can access your websocket by "ws://your_static_ip:port/ws". If you stick with the example code snippets your port number is likely 80.
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.