ESP32 websocket client misses first received message

biterror
Posts: 31
Joined: Thu Apr 30, 2020 11:00 am

ESP32 websocket client misses first received message

Postby biterror » Thu Apr 30, 2020 11:22 am

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!

Haresh Prajapati
Posts: 2
Joined: Sat Jan 30, 2021 9:46 am

Re: ESP32 websocket client misses first received message

Postby Haresh Prajapati » Mon Dec 11, 2023 11:09 am

Did you find any solution?
I am also facing same problem.

biterror
Posts: 31
Joined: Thu Apr 30, 2020 11:00 am

Re: ESP32 websocket client misses first received message

Postby biterror » 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?

Haresh Prajapati
Posts: 2
Joined: Sat Jan 30, 2021 9:46 am

Re: ESP32 websocket client misses first received message

Postby Haresh Prajapati » Tue Dec 12, 2023 4:19 am

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)

locustcox
Posts: 20
Joined: Tue Sep 04, 2018 9:36 pm

Re: ESP32 websocket client misses first received message

Postby locustcox » Sat Mar 23, 2024 3:33 pm

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.

rsaxvc
Posts: 1
Joined: Wed Mar 27, 2024 2:04 am

Re: ESP32 websocket client misses first received message

Postby rsaxvc » Wed Mar 27, 2024 2:07 am

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.

Who is online

Users browsing this forum: No registered users and 433 guests