[CSHARP-2067] TcpStreamFactory.ConnectAsync should use Socket.ConnectAsync Created: 17/Oct/17 Updated: 28/Oct/23 Resolved: 23/Oct/18 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Connectivity |
| Affects Version/s: | 2.4.4 |
| Fix Version/s: | 2.7.1 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Gian Maria Ricci | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
When TcpStreamFactory.ConnectAsync was first implemented the .NET Core implementation of Socket did not have a ConnectAsync method so it was simulated by using Task.Run. Our current dependency for the .NET Standard artifacts of the .NET driver is on .NET Standard 1.5, which does support Socket.ConnectAsync. So we can update our code to use Socket.ConnectAsync now that it is available. Note: see pull request. Original Description I have a project with xunit and dotnetcore, and during unit testing I have the below exception only if 1) I use not localhost but the IP of the machine I've debugged the driver and I'll submit a pull request. A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector { AllowedLatencyRange = 00:00:00.0150000 }}. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: " { ClusterId : 1, EndPoint : "10.0.0.40:27017" }", EndPoint: "10.0.0.40:27017", State: "Disconnected", Type: "Unknown" }] }. |
| Comments |
| Comment by Githook User [ 06/Nov/18 ] |
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: |
| Comment by Githook User [ 06/Nov/18 ] |
|
Author: {'name': 'Gian Maria Ricci', 'email': 'ricci.gianmaria@gmail.com', 'username': 'alkampfergit'}Message: |
| Comment by Githook User [ 23/Oct/18 ] |
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: |
| Comment by Githook User [ 23/Oct/18 ] |
|
Author: {'name': 'Gian Maria Ricci', 'email': 'ricci.gianmaria@gmail.com', 'username': 'alkampfergit'}Message: |
| Comment by Sebastian Alonso [ 30/Oct/17 ] |
|
Hi @alkampfer we are facing the same problem here, running the mongo driver inside aspnet core webapi (from vs2017 or dotnet windows command line or even inside docker containers) is just fine, but the timeout exception is triggered when running tests with xunit and connecting to a remote mongodb via IP (the mongodb server is running inside a docker container). Will this PR be merged soon? Thanks |
| Comment by Gian Maria Ricci [ 17/Oct/17 ] |
|
I've done a pull request, that in my specific situation solves the problem: https://github.com/mongodb/mongo-csharp-driver/pull/297 |