Skip to content
New issue

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

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

Already on GitHub? # to your account

Deadlock on Stop() #139

Open
zeroed-tech opened this issue Sep 22, 2023 · 0 comments
Open

Deadlock on Stop() #139

zeroed-tech opened this issue Sep 22, 2023 · 0 comments

Comments

@zeroed-tech
Copy link

Hi,
I've reciently started testing my Microsoft.Extensions.Hosting based console application outside Visual Studio and noticed when I kill the app using Ctrl+c, the shutdown process is getting blocked by client.Stop()

await client.StartOrFail();
outboxProcessor = OutboxProcessor(client, token);
await Task.WhenAll(outboxProcessor);
Logger.LogInformation("Closing socket");
await client.StopOrFail(WebSocketCloseStatus.NormalClosure, "Shutting down service");
Logger.LogInformation("Done");

I rebuilt my app using the Websocket-client source and stepped through it and it appears the lockup occurs when calling client.CloseAsync inside StopInternal() which as far as I can tell, is the boundrary between this library and .NET's own code.

I noticed that if I kill the connection from the server end, the DisconnectionHappened event fires with a type of DisconnectionType.ByUser (which can be seen in the below image).
image

Its like after I call stop, the client it trying to send a message but it getting blocked, and it only gives up when the other end kills the connection.

Any suggestions/recommendations?
Thanks

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

No branches or pull requests

1 participant