-
Notifications
You must be signed in to change notification settings - Fork 135
Description
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).

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