[CSHARP-3094] System.TimeoutException when connecting mongodb using .net core driver with docker Created: 07/May/20 Updated: 18/May/20 Resolved: 18/May/20 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Connectivity |
| Affects Version/s: | 2.9.0, 2.10.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | baichun mu | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
linux docker |
||
| Description |
|
Hello, I have a .net core program run in linux docker container. When I run the program in docker , the program fail to connect mongodb with replica set due to serverselectiontimeout. and it report below errors. We set a long time out 3-4 minutes, it could be connected. But too slow to connect mongodb. If I run in linux using dotnet run, the program is normal without connection issue. The issue born us a long time. Any solutions? how to resolve the issue? ///////////////////////////////////////////////////////////////////////////////// Environment info: Mongodb driver version 2.10.4, actually, we try from 2.9.0 to 2.10.4, neither one works Mongodb version 4.2 .Net core version 3.1 Linux version: centos-release-7-7.1908.0.el7.centos.x86_64 Docker version: we try on 18.09.6, build 481bc77156 and 19.03.5, build 633a0ea ///////////////////////////////////////////////////////////////////////////////// Error message: System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector { AllowedLatencyRange = 00:00:00.0150000 }}. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: " { ClusterId : 1, EndPoint : "Unspecified/ serverFQN:29031" }", EndPoint: "Unspecified/serverFQN:29031", State: "Disconnected", Type: "Unknown", LastUpdateTimestamp: "2020-05-06T08:50:17.7201620Z" }, { ServerId: " { ClusterId : 1, EndPoint : "Unspecified/serverFQN:29032" }", EndPoint: "Unspecified/serverFQN:29032", State: "Disconnected", Type: "Unknown", LastUpdateTimestamp: "2020-05-06T08:50:17.7260395Z" }, { ServerId: " { ClusterId : 1, EndPoint : "Unspecified/serverFQN:29033" }", EndPoint: "Unspecified/ serverFQN:29033", State: "Disconnected", Type: "Unknown", LastUpdateTimestamp: "2020-05-06T08:50:17.7265232Z" }] }. /////////////////////////////////////////////////////////////////////////////////// Sample code we used when connect mongodb: var clientSettings = MongoClientSettings.FromConnectionString(url); ; catch (Exception e) { System.Console.WriteLine(e); }
/////////////////////////////////////////////////////////////////////////////////// docker file content: FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build FROM build AS publish FROM base AS final
|
| Comments |
| Comment by Esha Bhargava [ 18/May/20 ] |
|
Thanks for your report. Please note that this project is for reporting bugs or feature suggestions for the driver. For MongoDB-related support discussion please post on the MongoDB Community Forums. A question like this involving more discussion would be best posted on the MongoDB community. |