CancellationToken when request gets aborted #21
-
Hi, is there any |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hello. Unfortunately, there is no way to know if the connection was closed by the client until you try to write or read something. It's a current limitation of the HttpListener in the .NET Core implementation. Before, in the .NET Framework, there was a method called RegisterForDisconnectNotification that, through reflection, would make it possible to obtain a token for client disconnection, but apparently it was removed in the new implementations of .NET. The client can disconnect and the internal stream continue active. As I mentioned, it's only possible to know if the client disconnected if you try to write or read that stream. Perhaps when the Cadente is set as the HTTP engine of Sisk, it will be possible to do this, because we will have access to the socket in its entirety, but for now, I don't know a way to make something that works this way on Windows, Linux, and OSX. |
Beta Was this translation helpful? Give feedback.
Hello.
Unfortunately, there is no way to know if the connection was closed by the client until you try to write or read something. It's a current limitation of the HttpListener in the .NET Core implementation. Before, in the .NET Framework, there was a method called RegisterForDisconnectNotification that, through reflection, would make it possible to obtain a token for client disconnection, but apparently it was removed in the new implementations of .NET.
The client can disconnect and the internal stream continue active. As I mentioned, it's only possible to know if the client disconnected if you try to write or read that stream. Perhaps when the Cadente is set as the HTTP engine of Sisk,…