RTC Forums
May 19, 2024, 07:24:46 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Multiples RTC WebSocket connexions in one http connexion  (Read 3595 times)
Ecole7
RTC Expired
*
Posts: 23


« on: April 22, 2017, 07:02:39 PM »

Hello

Concerning the program "WSockServTest" I note that if you refresh the browser page the number of Websocket connections displayed increases each time, but when you close the browser all connections are closed. This is true for all browser except for Internet explorer which closes each time the previous connection ...

My question is: how can we handle this problem to have a standard behavior for all browsers.

Greetings

Vincent Blanc
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: April 22, 2017, 08:18:38 PM »

After a HTTP connection has been upgraded to a Web Socket, the TCP/IP connection previously used for HTTP communication can ONLY be used to send and receive Web Socket "Frames". Sending or receiving HTTP requests or responses through that same connection is no longer possible. In other words, a Web Browser (or any other Client) can NOT use one HTTP connection to open multiple Web Sockets.

Normally, Clients should close TCP/IP connections when they are no longer used, but nothing is stopping a Web Browser (or any other Client) from opening a new TCP/IP connection, sending a new HTTP request through that new TCP/IP connection and upgrading that new connection to a Web Socket, while at the same time leaving the old TCP/IP connection open (which also leaves the old Web Socket open - until the TCP/IP connection is closed).

Most Web Browsers will be sending a WebSocket "Frame" with the opcode "Close" when they are finished using a Web Socket. In the OnWSDataReceived event, you can check if Sender.FrameIn.wfOpcode=ws_Close, which usually means that the connection is no longer needed and can safely be closed.

You can close any RTC connection (HTTP, TCP/IP or a Web Socket) by using the "Disconnect" method, or ... you can use one of the "wsDisconnect" methods to close one or more Web Socket connections.

Best Regards,
Danijel Tkalcec
Logged
Ecole7
RTC Expired
*
Posts: 23


« Reply #2 on: April 24, 2017, 07:41:51 AM »

Hello,
Thanks for the very quick and complete answer on how Websockets work.
I actually noticed that on some browsers, if you reload a page, the previous connection remains open for about ten seconds before closing.

So now everything is clear to me about this.

Greetings
Vincent Blanc
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 16 queries.