-
Notifications
You must be signed in to change notification settings - Fork 95
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
poll() disconnects client #139
Comments
Haven't use this library in a long time but: You are polling again which is fine but if it's true you again accept the connection, that would be an issue, no? What happens when you only poll it, does it disconnect again? |
After accepting the first connection, the result of poll() is false, as expected, so therefore the if block doesn't get executed. Nevertheless the client gets disconnected. |
Okay, you're connecting first, then you are reading the message in a blocking manner and then you additionally wait one second. I don't see you sending a heartbeat to the server so maybe the server doesn't recognize you as connected anymore? I know that I had an issue like that and I was sending a heartbeat connection every second or so. I used lambdas to receive messages from the client without actually stopping the main loop. Here's the directory with both my declaration and implementation if that helps/ Edit: Here's my loop as well. |
Unfortunately I'm not sure how to send a heartbeat and I don't just want to send random garbage. Shouldn't the TCP connection be maintained by the library itself or by an underlying level? Interestingly I can also wait more than 1 second... like 5 or even 10. The client gets only disconnected as soon when I call poll() again. |
No, heartbeats need to be sent manually because heartbeats depend on the
technology the server uses. On my server it was Elixir/Phoenix so I had to
send heartbeats specifically for that.
Can you try a basic websocket server maybe via python? I don't know the
cause of this issue.
…On Sat, Dec 3, 2022, 23:29 the-powl ***@***.***> wrote:
Unfortunately I'm not sure how to send a heartbeat and I don't just want
to send random garbage. Shouldn't the TCP connection be maintained by the
library itself or by an underlying level? Interestingly I can also wait
more than 1 second... like 5 or even 10. The client gets only disconnected
as soon as I call poll() again.
—
Reply to this email directly, view it on GitHub
<#139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGL5YIAUZAG26WOPJ6LCDLWLPCTHANCNFSM6AAAAAASHCMUUU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
omg I'm stupid. I oversaw a websocket.close() in my partly copy and pasted javascript code which was responsible for closing the connection. I got suspicious when I tried to use another arduino library and it still didn't work 🤣. Thanks for help! |
Yep, that about sums 1/2 of the problems when being a dev. Cheers! |
I'm trying to call poll() in a loop for checking on incoming connections and if true create a WebsocketsClient named client. As soon as a client is connected though, it gets disconnected again when the loop rolls over and reaches if(server.poll()) again. I found out via placing Serial.println() commands in between every step. If I never call poll() again, the client never disonnects.
I'm using it on an ESP8266. Library version is 0.5.3. Websocket connection is established via a simple html/js document, which does not initiate the disconnect on its own.
Here's a minimized code:
Am I doing something wrong?
The text was updated successfully, but these errors were encountered: