Closed brychanrobot closed 8 months ago
Update. I did get it to connect. It seems to always fail the first attempt and succeed on the second. Not sure why that is. Maybe my web task pool is too small so it's just getting dropped?
I've added a feature in version 0.6.0 where you can configure if the TCP connection is closed or kept alive after the response has been sent. Does closing the connection after the response has been sent solve the problem?
I have the same problem. Embassy based RP2040 project I have been playing with. Websockets work fine in Picoserve up to version 0.5. With Picoserve 0.6 creating websocket always fails. Keepalive does not seem to affect things.
Websockets work fine in Picoserve up to version 0.5. With Picoserve 0.6 creating websocket always fails. Keepalive does not seem to affect things.
Thanks for the additional info, I think that I've found the problem. In picoserve 0.6, a websocket response has a repeated "Connection" header, one with "keep-alive", and the other with "upgrade", which causes problems. I've put a fix on the branch "fix-websockets", are you OK to test it? If it still doesn't work, are you OK to send me the code (or a link to it) so that I can test things at my end?
Thanks all for the help, much appreciated :D
Seems that "fix-websockets" solves the issue. I only had time for quick test but web socket creation succeeded both with and without keepalive.
I've now merged "fix-websockets" into main
Is websocket expected to work on embassy? I tried to set them up working from https://github.com/sammhicks/picoserve/blob/main/examples/web_sockets/src/main.rs, and the requests just fail on the browser side. I'm not sure why that would be. Other requests for
/
and others work fine, but when I try to create anew WebSocket()
in the js, theGET
request never even shows up on the microcontroller.The very reduced route for
/ws
just to see if theGET
request is even coming in.The WebSocket constructor in js. This is run from the index.html|js that are hosted on the microcontroller.
Chrome console error message
index.js:66 WebSocket connection to 'ws://test-hostname.lan:8000/ws' failed:
Firefox console error message
Firefox can’t establish a connection to the server at ws://test-hostname:8000/ws