-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sendBIN w/ headerToPayload seems unstable? (ESP8266) #350
Comments
The used heap in the test program is adjustable. When headerToPayload is enabled it is unstable w/ 8k, and stable with 20k. I haven't tested a lot to find the breaking point. With as little as 4k of ram, I can reliably send long bursts of 256b packets UNLESS headerToPayload is enabled. and 256b of that is used to make the payload buffer. Results of enabling those logging statements using the same settings as in the example gist: |
playing around with the test program, I can send 1024b payloads with only 2184b of heap free (after payload is allocated) as long as headerToPayload is false. |
Hey I think I found it. The code in ClientContext.h calls it should look like this:
thats esp8266 core right? now to figure out how to fork and PR :) |
When the system is under memory pressure, headerToPayload seems to break, sending frames that causes the browser to close the connection. e.g. in chrome many different errors can appear such as:
attaching a test setup in this gist including a program to run on an ESP8266 and an html page to drive it:
https://gist.github.com/simap/6723beab8668035d19b9d7f8aea07b2e
Clicking connect, then on the "Test w headerToPayload" button allocates a buffer with an extra
WEBSOCKETS_MAX_HEADER_SIZE
bytes, then writes offset by that, and calls sendBIN w/ headerToPayload true.In the code, if fillSize is set to a small number reducing memory pressure, everything works OK.
This seems counterintuitive, since headerToPayload is supposed to reduce an extra malloc + memcpy in some cases.
It also breaks with some smaller payloads e.g.:
The text was updated successfully, but these errors were encountered: