<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:44:21 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-3094] System.TimeoutException when connecting mongodb using .net core driver with docker</title>
                <link>https://jira.mongodb.org/browse/CSHARP-3094</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;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.&#160; If I run in linux using dotnet run, the program is normal without connection issue.&#160; The issue born us a long time. Any solutions? how to resolve the issue?&lt;/p&gt;

&lt;p&gt;/////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Environment info:&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;Mongodb driver version 2.10.4, actually, we try from 2.9.0 to 2.10.4, neither one works&lt;/p&gt;

&lt;p&gt;Mongodb version 4.2&lt;/p&gt;

&lt;p&gt;.Net core version 3.1&lt;/p&gt;

&lt;p&gt;Linux version: centos-release-7-7.1908.0.el7.centos.x86_64&lt;/p&gt;

&lt;p&gt;Docker version: we try on 18.09.6, build 481bc77156 and 19.03.5, build 633a0ea&lt;/p&gt;

&lt;p&gt;/////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Error message:&lt;/b&gt;&#160;&lt;/p&gt;

&lt;p&gt;System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector&lt;/p&gt;
{ AllowedLatencyRange = 00:00:00.0150000 }
&lt;p&gt; }. Client view of cluster state is { ClusterId : &quot;1&quot;, ConnectionMode : &quot;ReplicaSet&quot;, Type : &quot;ReplicaSet&quot;, State : &quot;Disconnected&quot;, Servers : [{ ServerId: &quot;&lt;/p&gt;
{ ClusterId : 1, EndPoint : &quot;Unspecified/ serverFQN:29031&quot; }
&lt;p&gt;&quot;, EndPoint: &quot;Unspecified/serverFQN:29031&quot;, State: &quot;Disconnected&quot;, Type: &quot;Unknown&quot;, LastUpdateTimestamp: &quot;2020-05-06T08:50:17.7201620Z&quot; }, { ServerId: &quot;&lt;/p&gt;
{ ClusterId : 1, EndPoint : &quot;Unspecified/serverFQN:29032&quot; }
&lt;p&gt;&quot;, EndPoint: &quot;Unspecified/serverFQN:29032&quot;, State: &quot;Disconnected&quot;, Type: &quot;Unknown&quot;, LastUpdateTimestamp: &quot;2020-05-06T08:50:17.7260395Z&quot; }, { ServerId: &quot;&lt;/p&gt;
{ ClusterId : 1, EndPoint : &quot;Unspecified/serverFQN:29033&quot; }
&lt;p&gt;&quot;, EndPoint: &quot;Unspecified/ serverFQN:29033&quot;, State: &quot;Disconnected&quot;, Type: &quot;Unknown&quot;, LastUpdateTimestamp: &quot;2020-05-06T08:50:17.7265232Z&quot; }] }.&lt;br/&gt;
 at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)&lt;br/&gt;
 at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)&lt;br/&gt;
 at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.MongoClient.StartImplicitSession(CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession&lt;span class=&quot;error&quot;&gt;&amp;#91;TResult&amp;#93;&lt;/span&gt;(Func`2 func, CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.MongoCollectionImpl`1.FindSync&lt;span class=&quot;error&quot;&gt;&amp;#91;TProjection&amp;#93;&lt;/span&gt;(FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken cancellationToken)&lt;br/&gt;
 at MongoDB.Driver.IAsyncCursorSourceExtensions.ToList&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;(IAsyncCursorSource`1 source, CancellationToken cancellationToken)&lt;br/&gt;
 at PwC.Ms.Console.Program.Main(String[] args) in /src/console/Program.cs:line 81&lt;/p&gt;

&lt;p&gt;///////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;

&lt;p&gt;Sample code we used when connect mongodb:&lt;/p&gt;

&lt;p&gt;&#160;var clientSettings = MongoClientSettings.FromConnectionString(url);&lt;br/&gt;
 if (requireSsl)&lt;br/&gt;
 {&lt;br/&gt;
 clientSettings.SslSettings = new SslSettings &lt;/p&gt;
{ ServerCertificateValidationCallback = (sender, certificate, chain, errors) =&amp;gt; true, 
 CheckCertificateRevocation = false}
&lt;p&gt;;&lt;br/&gt;
 clientSettings.VerifySslCertificate = false;&lt;br/&gt;
 clientSettings.UseSsl = true;&lt;br/&gt;
 clientSettings.AllowInsecureTls = true;&lt;br/&gt;
 }&lt;br/&gt;
 try&lt;/p&gt;
 {
 clientSettings.ServerSelectionTimeout = TimeSpan.FromMinutes(5);
 var client = new MongoClient(clientSettings); 
 var database = client.GetDatabase(dbName);
 var fileFilter = Builders&amp;lt;BsonDocument&amp;gt;.Filter.Exists(&quot;_id&quot;);
 var file1 = database.GetCollection&amp;lt;BsonDocument&amp;gt;(&quot;fs.files&quot;).Find(Builders&amp;lt;BsonDocument&amp;gt;.Filter.Empty).ToList();
 System.Console.WriteLine(file1.Count);
 var file2 = database.GetCollection&amp;lt;BsonDocument&amp;gt;(&quot;fs.files&quot;).Find(Builders&amp;lt;BsonDocument&amp;gt;.Filter.Empty).ToList();
 System.Console.WriteLine(file2.Count);
 var file3 = database.GetCollection&amp;lt;BsonDocument&amp;gt;(&quot;fs.files&quot;).Find(Builders&amp;lt;BsonDocument&amp;gt;.Filter.Empty).ToList();
 System.Console.WriteLine(file3.Count);
 }
&lt;p&gt; catch (Exception e)&lt;/p&gt;
 {
 System.Console.WriteLine(e);
 }

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;///////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;

&lt;p&gt;docker file content:&lt;/p&gt;

&lt;p&gt;FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim AS base&lt;br/&gt;
WORKDIR /app&lt;/p&gt;

&lt;p&gt;FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build&lt;br/&gt;
WORKDIR /src&lt;br/&gt;
COPY &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;console/Ms.Console.csproj&amp;quot;, &amp;quot;console/&amp;quot;&amp;#93;&lt;/span&gt;&lt;br/&gt;
RUN dotnet restore &quot;console/Ms.Console.csproj&quot;&lt;br/&gt;
COPY . .&lt;br/&gt;
WORKDIR &quot;/src/console&quot;&lt;br/&gt;
RUN dotnet build &quot;Ms.Console.csproj&quot; -c Release -o /app/build&lt;/p&gt;

&lt;p&gt;FROM build AS publish&lt;br/&gt;
RUN dotnet publish &quot;Ms.Console.csproj&quot; -c Release -o /app/publish&lt;/p&gt;

&lt;p&gt;FROM base AS final&lt;br/&gt;
WORKDIR /app&lt;br/&gt;
COPY --from=publish /app/publish .&lt;br/&gt;
ENTRYPOINT &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;dotnet&amp;quot;, &amp;quot;Ms.Console.dll&amp;quot;&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment>linux docker</environment>
        <key id="1342767">CSHARP-3094</key>
            <summary>System.TimeoutException when connecting mongodb using .net core driver with docker</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="baichun.mu@cn.pwc.com">baichun mu</reporter>
                        <labels>
                    </labels>
                <created>Thu, 7 May 2020 03:45:26 +0000</created>
                <updated>Mon, 18 May 2020 22:29:05 +0000</updated>
                            <resolved>Mon, 18 May 2020 22:29:05 +0000</resolved>
                                    <version>2.9.0</version>
                    <version>2.10.4</version>
                                                    <component>Connectivity</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3094023" author="esha.bhargava" created="Mon, 18 May 2020 22:28:55 +0000"  >&lt;p&gt;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 &lt;a href=&quot;https://community.mongodb.com/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MongoDB Community Forums&lt;/a&gt;. A question like this involving more discussion would be best posted on the MongoDB community.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hx7bwf:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>