Skip to content

CancellationToken when request gets aborted #21

Answered by CypherPotato
chylex asked this question in Q&A
Discussion options

You must be logged in to vote

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,…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@chylex
Comment options

@CypherPotato
Comment options

@chylex
Comment options

@CypherPotato
Comment options

@chylex
Comment options

Answer selected by chylex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants