U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » How to close the websocket connection
Re: How to close the websocket connection [message #49487 is a reply to message #49459] Sat, 17 February 2018 12:01 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14290
Registered: November 2005
Ultimate Member
uppjj wrote on Wed, 14 February 2018 19:17
Hello
I got the same problem, "Close" put my websocket client in infinite loop.
Server receives the "Close" message from the client but does not actually send the response, because it is in non-blocking mode.
I just do this change in uppsrc/core/WebSocket.cpp , function "out":

// while(IsBlocking()  && socket->IsOpen() && !IsError() && out_queue.GetCount())
   while((IsBlocking() || (s[0] == CLOSE))  && socket->IsOpen() && !IsError() && out_queue.GetCount())


and got "Close" working well...


Thanks. I believe this has a problem of occassionally turning nonblocking socket into blocking, as Out is used for data too.

I suggest this:


void WebSocket::Out(const String& s)
{
	out_queue.AddTail(s);
	while((IsBlocking() || close_sent) && socket->IsOpen() && !IsError() && out_queue.GetCount())
		Output();
}



Would that work for you?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Vector<Vector<double>>
Next Topic: how to convert unicode to String
Goto Forum:
  


Current Time: Sat Apr 25 20:25:44 GMT+2 2026

Total time taken to generate the page: 0.01369 seconds