npgsql: Frontend timeouts for async methods

Npgsql performs frontend (i.e. socket) timeouts, in case the connection is dropped while waiting for a response (half-open connection). However, socket timeouts are only applied to synchronous operations (https://msdn.microsoft.com/en-us/library/system.net.sockets.socket.receivetimeout(v=vs.110).aspx).

It’s not 100% clear whether frontend timeouts should be implemented for async operations as well. The old-style async methods such as BeginExecuteAsync very explicitly ignore CommandTimeout (https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.commandtimeout(v=vs.110).aspx). On the other hand, the docs for the .NET 4.5 ExecuteReaderAsync states that The cancellation token can be used to request that the operation be abandoned before the command timeout elapses, implying that the command timeout is respected.

Note that async operations already have backend timeouts just like sync operations.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Reopening as https://github.com/dotnet/corefx/issues/24430 added cancellation token support to socket operations, which we can use to implement timeouts (see also https://github.com/dotnet/corefx/issues/9698).

@YohDeadfall I’m here