RTC Forums
November 23, 2024, 08:38:21 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
>
WebSocket close code
Pages: [
1
]
« previous
next »
Print
Author
Topic: WebSocket close code (Read 4989 times)
Ecole7
RTC Expired
Posts: 23
WebSocket close code
«
on:
June 02, 2017, 06:37:18 PM »
Hello,
I would like to be able to get a valid closing code (1000) to be retrieved on the WEB client side, when I call the wsDisconnect function.
The goal would be to make the difference if the closure comes from the server or the WEB client.
For now I still get code 1006 which is an error.
Thank you for your reply.
Vincent
Logged
D.Tkalcec (RTC)
Administrator
Posts: 1881
Re: WebSocket close code
«
Reply #1 on:
June 02, 2017, 07:52:31 PM »
Calling
wsDisconnect
closes the physical connection, which is a perfectly valid way for a Web Server to close a WebSocket connection and is correctly handled by some Web Browsers as a closed WebSocket, but ... other WebBrowsers could interpret a closed connection as an error, if there was no "CLOSE" Frame sent or received before the connection was closed.
You can always send a "CLOSE" frame to the other side by using one of the
wsSend
methods with the
wf_Close
"opcode" and an optional "payload" (see WebSocket specification for details), for example by calling
Sender.wsSend(wf_Close)
from inside a WebSocket event (like OnWSDataReceived).
You can also implement the
OnWsDataReceived
event to call
wsDisconnect
if a
wf_Close
frame is received from the other side, and send a
wf_Pong
frame if a
wf_Ping
frame is received.
But ... some WebBrowsers do NOT have a correct handler for the "CLOSE" frame, because of which sending a "CLOSE" frame can also give you an ERROR in some Web Browsers. Unfortunately, there is nothing I can do about the way Web Browsers implement WebSockets, so ... you will need to "tinker" and experiment a lot, if you want to make your Web Application behave the same with all major Web Browsers.
Best Regards,
Danijel Tkalcec
Logged
Ecole7
RTC Expired
Posts: 23
Re: WebSocket close code
«
Reply #2 on:
June 03, 2017, 07:25:07 PM »
Thank you for all this clarifications that have been very helpful in solving my problem.
I modified my software and I no longer use the "closes code" and everything works very well.
I am impressed by your quasi-encyclopedic knowledge in network programming.
As far as I am concerned, I do not want to be pretentious in terms of my knowledge, I think that your implementation of WebSocket is the best that can be found on the market today.
Greetings
Vincent
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...