RTC Forums
November 23, 2024, 10:00:58 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Login
Register
RTC Forums
>
Subscription
>
Support
>
Multiples RTC WebSocket connexions in one http connexion
Pages: [
1
]
« previous
next »
Print
Author
Topic: Multiples RTC WebSocket connexions in one http connexion (Read 4347 times)
Ecole7
RTC Expired
Posts: 23
Multiples RTC WebSocket connexions in one http connexion
«
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
Re: Multiples RTC WebSocket connexions in one http connexion
«
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
Re: Multiples RTC WebSocket connexions in one http connexion
«
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
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...