❔ my socket changes his connected attribute to false right after i sucessfully received data :(
Hello community, i am writing a chatroom application, where i wrote a Task to receive messages. However, after i sucessfully received the first data, the socket changes his connected attribute to false, and my application stops.
I wonder why this happens, and i also dont understand why i dont get thrown into the Catch block, and instead the application closes.
The connected attribute changes to false immediately after the receiveAsync is sucessfully executed, at the begining of the Task.
On the second round of the while loop, my application closes at the receiveAsync line.
The Task is some lines, so i uploaded the code here: https://codeshare.io/6pZjop
I appreciate any help.
7 Replies
Don't use Connected property.
Please implement something like a heartbeat instead
as Connected property is the state of the last operation
I just wonder if that would help me? Because once the socket changes his attribute to connected = false, i cant receive any more messages.
A heartbear would be cool to check if users are indeed still online, but i dont think that helps with my problem :/ Right now the server simply removes a client, when it cant send a message to him because the socket is not connected anymore or similar.
I already checked if the server removes the client, but thats not the case. I dont get why the socket suddenly disconnects at the client side.
Remove the connected property and see again, If you still receieve messages
Unfortunatly not..
Do you have it set to keep alive?
Socket option
Gotta try that. Ty
Unfortunetly that didnt help, i am still trying to solve this somehow
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.