Page 1 of 1
ESP32 websocket client misses first received message
Posted: Thu Apr 30, 2020 11:22 am
by biterror
I am using the ESP32 websocket client (idf version v4.2-dev-701-g0ae960f2f-dirty) to connect to a linux box running a libwebsocket server. The server side sends out a JSON formatted message immediately after a new client connects. Other clients are receiving this message just fine, but the ESP32 ws client seems to miss the first message most of the time.
If I add a delay of 100 ms to the server (between connect and the message transmission), ESP32 gets the message most of the time. With a 250 ms delay, ESP32 gets 99.8% of the messages.
Is this a known bug in the ws client implementation? Does a fix exist?
EDIT: I updated to idf version v4.2-dev-1266-g2dc4bfe78-dirty, but the problem remains the same.
Thanks!
Re: ESP32 websocket client misses first received message
Posted: Mon Dec 11, 2023 11:09 am
by Haresh Prajapati
Did you find any solution?
I am also facing same problem.
Re: ESP32 websocket client misses first received message
Posted: Mon Dec 11, 2023 12:43 pm
by biterror
I believe the bug was not in lws but in Ethernet code and I think it has been fixed a long time ago. I'm not seeing any problems with Ethernet (running idf 4.4.6), but I'm not using lws in my current projects.
Which idf version are you using?
Re: ESP32 websocket client misses first received message
Posted: Tue Dec 12, 2023 4:19 am
by Haresh Prajapati
biterror wrote: ↑Mon Dec 11, 2023 12:43 pm
I believe the bug was not in lws but in Ethernet code and I think it has been fixed a long time ago. I'm not seeing any problems with Ethernet (running idf 4.4.6), but I'm not using lws in my current projects.
Which idf version are you using?
I am using idf 5.0.0
Whenever a websocket is connected to a server, the server sends some JSON data with the connection, but on esp side, I didn't get that.
I tried to `esp_websocket_client_start` and `esp_websocket_client_stop` websocket_client until I didn't receive that data.
but it is working after several tries (sometime works on two try, some time 10 or above and some time takes 10 minutes or more)
Re: ESP32 websocket client misses first received message
Posted: Sat Mar 23, 2024 3:33 pm
by locustcox
Issue still exists. My current workaround is to add a delay on my Python server before sending any messages since the first message gets dropped on the ESP32.
Re: ESP32 websocket client misses first received message
Posted: Wed Mar 27, 2024 2:07 am
by rsaxvc
One case seems to be if the server responds over HTTP during the protocol change:
https://github.com/espressif/esp-protocols/issues/396
If you have control of the server, you may try to delay sending to the client until the protocol change to websocket is completed.