Details
-
Bug
-
Resolution: Unresolved
-
Major - P3
-
None
-
2.4.4
-
None
-
.NET Core 2.0.0-preview2
Linux x64
Description
Occasinally when querying the database, we get the following exception:
MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.ObjectDisposedException: Cannot access a disposed object.
|
Object name: 'System.Net.Sockets.Socket'.
|
at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)
|
at MongoDB.Driver.Core.Connections.TcpStreamFactory.ConfigureConnectedSocket(Socket socket)
|
at MongoDB.Driver.Core.Connections.TcpStreamFactory.CreateNetworkStream(Socket socket)
|
at MongoDB.Driver.Core.Connections.TcpStreamFactory.<CreateStreamAsync>d__4.MoveNext()
|
--- End of stack trace from previous location where exception was thrown ---
|
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
|
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
|
at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__48.MoveNext()
|
--- End of inner exception stack trace ---
|
at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__48.MoveNext()
|
--- End of stack trace from previous location where exception was thrown ---
|
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
|
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
|
at MongoDB.Driver.Core.Servers.Server.<GetChannelAsync>d__27.MoveNext()
|
--- End of stack trace from previous location where exception was thrown ---
|
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
|
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
|
at MongoDB.Driver.Core.Operations.FindOperation`1.<ExecuteAsync>d__111.MoveNext()
|
--- End of stack trace from previous location where exception was thrown ---
|
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
|
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
|
at MongoDB.Driver.GridFS.GridFSBucket`1.<GetFileInfoByNameAsync>d__70.MoveNext()
|
--- End of stack trace from previous location where exception was thrown ---
|
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
|
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
|
at MongoDB.Driver.GridFS.GridFSBucket`1.<OpenDownloadStreamByNameAsync>d__29.MoveNext()
|
The strange part about this is that according to a stack trace it should be a newly created socket.
This might be a problem with low connection timeout (but I expect it to throw TimeoutException) and/or externally passed non-default cancellationToken, this looks like the only explanation how socket hapens to get disposed in TcpStreamFactory.ConnectAsync.
This also might be a bug in .NET Core 2.0-preview2 (especially since it's a preview), but I don't think so, the other network-related code in the application functions normally (though it doesn't rule this out completely).
In fact, if System.Threading.Timer had a bug that allowed it to fire after being disposed, this could lead to the described problem.
Attachments
Issue Links
- is related to
-
CSHARP-1646 TcpStreamFactory.ConfigureConnectedSocket Exception
-
- Closed
-