websocket-sharp icon indicating copy to clipboard operation
websocket-sharp copied to clipboard

The program will be blocked when we use the properties of isAlive Act…

Open sinolover opened this issue 5 years ago • 1 comments

…iveID and InactiveID and all methods relatived to ping undering the case of connectivity of any remote client was terminated suddenly.

That's a big problem when we use the software in real time data transferring and the network was interrupted unexpectedly, so I change them to asynchronous method with setting macro definition of __PING_ASYNC at property of project

1.Steps to reproduce: Start WebSocketServer Start two or more clients to connect to WebSocket Server Unplugged the net cable of one of clients' manually The property of isAlive ActiveID or InActiveID was used before sending message in WebSocketBehavior or the event of _sweepTimer was triggered at occasion of sending message.

2.Actual result: All other rest clients could not receiving any data from WebSocket Server in 10 to 30 seconds until the WebSocket Server receiving the event of that client was closed or offline.

3.Expected result: Send messages quickly and continusly

4.Proposed solution: Replacing the usage of the ping method with pingAsync

sinolover avatar Jan 08 '21 09:01 sinolover

Instead of completely rewriting the entire class, the IsAlive property should be marked as [Obsolete] with a very clear warning that it is a blocking operation so that developers know what they're getting themselves into and how they can do the same thing without a blocking operation. Additionally, a dedicated async Ping() method could provide the same functionality in a more intuitive way.

Coming from someone who had to spend 3 days to find out why the application was lagging until I realized that IsAlive wasnt just a simple value getter but actually performed a blocking operation underneath. Hiding such a method in a getter is not good design, especially without any warnings in the property description.

HeaX3 avatar Dec 09 '23 17:12 HeaX3