arduinoWebSockets
arduinoWebSockets copied to clipboard
setNoDelay on ESP32 causing error [E][WiFiClient.cpp:309] setOption(): fail on fd -1, errno: 9, "Bad file number"
Hi Markus,
on ESP32 it seems that setNoDelay(true)
does not work and causing the "Bad file number" error when WebSocketsClient connects to a server.
setNoDelay(true)
is called in connectedCb
in WebSocketsClient.cpp:
https://github.com/Links2004/arduinoWebSockets/blob/a14b6b73b4f05e189ca49d6e84202c2b55db528a/src/WebSocketsClient.cpp#L865-L866
I tried to follow the path to see where the error comes from, but I ended up in lwip_setsockopt_r
in lwip.h
At this point my knowledge left me :(
I think the ESP32 should be removed from from the #if
macro - what do you think?
I'm experiencing exactly the same issue. If I fail to connect a few times after getting this message I then get an out of memory exception. It's my understanding that “Bad File Number” error (Errno: 9) in a multithreaded application error, an “Opened once but closed twice” bug. So when thread “Y” carries out its second close(), it actually closes the file descriptor of thread “X”, which was valid & in use. I'm not sure if this is what is causing my our of memory exception, but since setNoDelay(true) disables the Nagle algorithm, that intends to reduce TCP/IP traffic of small packets sent over the network by combining a number of small outgoing messages, and sending them all at once, I think Boris' suggestion is a good one.
if the setNoDelay
is problematic on the ESP32 in some use cases we can remove it via the macro.
I'm facing the same issue. How would you remove it via the macro?
Hi Guys, I am facing the same issue was it fixed? If yes what was the fix. I did remove the setnodelay from the macro but no effect on error.