How to keep a websocket connection until either side is closed?

I would like to create a chat application on websocket and select Poco C ++ lib as the web server (1.4.6p1). There are several users at the same time, poco websocket will be blocked when reading, but will be automatically released after 60 seconds if nothing is received from the browser.

I want the socket to be connected to manage so many active (or inactive) users, but how do I get there?

Thx

+4
source share
2 answers

I “fixed” the problem with this simple and somewhat dirty line of code:

ws.setReceiveTimeout(Poco::Timespan(10, 0, 0, 0, 0)); 

Basically, I set the waiting time for admission to 10 days. Since my websocket will have a life expectancy of several hours, 10 days is infinity for me.

Hope this helps.

+7
source

Check this:

Poco :: Net Server and TCP Client Event Handler

You have some examples of how to wait for connections, timeouts, etc.

Good luck.

+2
source

All Articles