Closed sepehr1014 closed 5 years ago
@pan-wang @shirhatti
Any updates on this issue?
@Tratcher - where would you suspect that the underlying issue is? In ASP.NET Core? Kestrel? WebSockets middleware? IIS? ANCM?
ANCM/IIS or CoreFx WebSockets.
@Tratcher where do you think we should start? If the bug doesn't belong here, I'd like to at least move it to somewhere more likely.
By trying to repro with and without ANCM/IIS.
@jkotalik - could you take a look at this to see where it should go? Thanks!
@sepehr1014 just to clarify, does WebSocket.ReceiveAsync
ever return? Also, what version of ANCM are you using (specifically dll file version under Windows\System32\inetsrv.
If you have a repro available, please follow up by emailing me at the email listed on my github profile.
@jkotalik Sorry for my late response. I was using .NET Core 2.1.0 but I followed up extensively with @pan-wang and came to the conclusion that ping functionality is not yet implemented by ASP.NET Core. So we ended up sending an empty message every minute ...
ping functionality is not yet implemented by ASP.NET Core
When you say ASP.NET Core, do you mean the websocket middleware or ANCM itself? I'm fairly sure that AspNetCore implements pings.
Ping/pong is handled by windows websocket (networking) and winhttp separately and never hit ANCM. In the case of client disconnected and HTTP.sys did not notify ANCM, ANCM will not send the close frame. The back-end thus will not close the websocket connection and wait on the async receive. I could not repro this disconnect (missing client disconnect from HTTP.sys) issue locally. Need a repro app to further investigation. A workaround is to let the back-end sends some ping message periodically as SignalR does.
I'm experiencing this issue too with my app hosted in Azure App Service.
Is there a workaround for this? @pan-wang
@jkotalik I can repro this issue in IISExpress and IIS. The issue does not occur when running as a self-host server.
@moshegutman the workaround depends on the nature of the application. Could you please share your repro so that I can take a look? You can reach me at panwang(at)Microsoft(dot)com.
@pan-wang I've created a simple repo here: https://github.com/zlatanov/aspnetcore-websockets-experiments. A simple server that only ever expects Pings and replies with Pongs.
If you run it Kestrel, works as expected. If you run it with IIS or IIS Express, doesn't work. Connect a simple websocket client that doesn't do anything but send pings.
Is there any update? We are having issues responding to pings on Azure app service(ASP.NET CORE 2.1) similarly to everyone above. Is there a known workaround for this issue on app service(ASP.NET CORE 2.1)?
Are there any details when this issue will be addressed/fixed?
On another PC, where an old version of AspNetCoreModule was installed (version starting with 7.1), this bug would not reproduce. After upgrading the .NET Core Hosting Bundle with the latest version, the bug is reproducible.
@jkotalik / @pan-wang - any further ideas on this?
Talked to @jkotalik and he is investigating.
We've discovered the same bug in our WS prod code. Setting KeepAliveInterval = TimeSpan.FromSeconds(120) completely failed to detect an incorrectly shutdown client. We suspect this has lead to significant performance degradation due to increased load.
I'm running into this issue as well. Server is an Azure App service instance.
@Eilon @jkotalik Can you share any information about the status of this issue?
@zlatanov we are working on a resolution to this issue - we will provide an update in this issue when we have more to report.
Any information about this ? still not working in ASP.NET Core 2.2.2
What isn’t working? In 2.2 we added pings from client to server as well. It has nothing to do with the keep alive interval and in fact you shouldn’t configure that separately because we disable it in favor of our own pings
@davidfowl What do you mean by your "own" pings? Is there any documentation on how ping-pong should be implemented in ASP.NET Core?
Ah my bad I was thinking this was a SignalR issue
So how would you terminate the connection on failed keepalive basically ?
@davidfowl I have created a Unit Test to illustrate the issue. The branch with the test is here - https://github.com/zlatanov/AspNetCore/tree/ws-keep-alive-issue.
The actual test - https://github.com/zlatanov/AspNetCore/blob/f21fcd3f3ab7b0f585385a65701160e6a4ad6ad0/src/Middleware/WebSockets/test/UnitTests/SendReceiveTests.cs#L109.
The NET Core WebSocket client does send a keep alive frame, but the server socket never receives it.
Hey all, the issue originally state with websockets and IIS is fixed fixed. Please download the latest versions of 2.1, 2.2, and 1.x: https://dotnet.microsoft.com/download/dotnet-core/2.1, https://dotnet.microsoft.com/download/dotnet-core/2.2, and https://dotnet.microsoft.com/download/dotnet-core/1.1.
@zlatanov are you using IIS in that unit test? It doesn't look like it, so you may have a different issue.
Closing as the original issue is resolved.
We're using .NET Core 2.1 RC1 and we've set keep-alive interval using
app.UseWebSockets(new WebSocketOptions() { KeepAliveInterval = TimeSpan.FromSeconds(10) })
But when the client is disconnected without sending the close frame (because of connection loss or power outage for instance),
WebSocket.ReceiveAsync
does NOT return even after 10 seconds. My understanding is that if the server is not receiving a pong frame in 10 seconds, the connection should be regarded as dead andReceiveAsync
should return an empty result.BTW this is behind IIS on Windows Server 2016 with the latest updates installed. We've also set IIS ping pong in application host config. (Though as far as I know .NET Core 2.1 does not use libuv anymore and sockets are handled in managed code)