Open vndlczndr opened 7 years ago
best way to start is to enable debug.
https://github.com/Links2004/arduinoWebSockets/blob/ATmega/src/WebSockets.h#L30
for AVR you need to get printf working since it is not supported out of the box there.
read Adding printf() to Print class
in
https://playground.arduino.cc/Main/Printf
Thank you for your fast response! When I enable debug mode, the output of the server looks like this: (I commented the "Serial.print" commands in my sketch to show the server output only) https://prnt.sc/g00m23 I also tried to change the maximum client count to 4 in WebSocketsServer.h at line 31, it did not help.
G.
the most likely the problem is around: https://github.com/Links2004/arduinoWebSockets/blob/ATmega/src/WebSocketsServer.cpp#L382 for some reason there we get a valide ptr there. then a client is created with this invalide socket, which then is closed again.
Thank you, I'll look into that part and I'll try to find out what causes the problem!
G.
Soo, I managed to discover some (I think) problems and made some (I think) solutions. Your code checks if there is data waiting with the NETWORK_ESP8266, but not with W5100, so the for cycle at 373 will always run. I added these lines after line 373,
#else
if (_server->available()) {
#endif
and commented the #if - #endif at line 422, 424. This solved the continuous new client issue, but not the next one: http://prntscr.com/gfax5t As the processing of the client headers is one header line at a time, the handleNewClients method will be called multiple times while a client is reading the header lines. To solve this issue, modified the handleClientData method too. I replaced
int len = client->tcp->available();
if(len > 0) {
with
while (client->tcp->available() > 0) {
and this one solved the next issue too.
Of course we are not out of the water yet. This time the websocket server works almost fine, but:
Every time it gets a packet, as there is new data, _server->available() will be true and it will try to add a new client. Itt will not succeed of course, but the space will be given to this 'not real' new client, and it will try to decode the data:
https://justpaste.it/1aq10
This is where I am standing now.
Any thoughts?
G.
Has anybody solved this issue? I keep getting the same continual polling of WStype_DISCONNECTED
I got as close as G-Hooper, did anyone fix it? E.g. WebSockets with WS5100 fails with [WSc] Disconnected, ...if not I will re-write it as it's a mess.. way to many #if WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266, Better to have different lib.
I'm using this library with Teensy-LC. (WebSocketsServer V1.3) I'm having exactly the same repeated disconnect problem. I've made the 2 changes suggested by VendelCzinder, and it does behave much better, but as he mentioned, that is not the full solution. Did anyone find a full solution to the problem?
Hi!
I am trying to create a small websocket echo server with this arduinoWebSockets library, but I just cannot make it work. When I start the program (code below) on the Arduino, it just starts calling the callback function endlessly with the WStype_t being 1 (WStype_DISCONNECTED). The code runs on an Arduino Mega with an Ethernet Shield. Edit: I am using the ATMega branch.
The source code:
So right now I'm looking for some solution or guidance about what I'm doing wrong. I appreciate any help I can get! Thank you!
G.