-->
Page 4 of 4

Re: multiple connect to ESP serve in same time

PostPosted: Thu Jun 08, 2017 12:05 am
by Pablo2048
Try to use Async version of the webserver (and websocket) libraries ( https://github.com/me-no-dev/ESPAsyncWebServer ). It's very fast and can handle multiple clients at the same time. Also Your websocket can be on the same port as webserver.

Re: multiple connect to ESP serve in same time

PostPosted: Thu Jun 08, 2017 4:40 pm
by gbafamily1
The function webSocket.broadcastTXT() sends the same data to all connected websocket clients.

In your code, data is sent to the websocket client specified by socketNumber but socketNumber is overwritten whenever a new client is connected so the old client stops receiving data.

String temp_str = String(temp_int);
webSocket.sendTXT(socketNumber, "wpMeter,Arduino," + temp_str + ",1");

Try the following.

webSocket.broadcastTXT("wpMeter,Arduino," + temp_str + ",1");

In addition, delay(200) as well as calls to blocking functions such as readStringUntil() will cause problems. loop() and all the functions it calls must avoid calls to delay() and blocking functions.