Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sinolover
Copy link

…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

…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
@HeaX3
Copy link

HeaX3 commented Dec 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants