<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:17 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-255] SocketException on MongoServer.Connect()</title>
                <link>https://jira.mongodb.org/browse/CSHARP-255</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;This mongo url fails with the 1.1 c# driver and works with the 1.0 driver &lt;/p&gt;

&lt;p&gt;mongodb://xxxx:40000,xxxx:40001,xxxx:40002/?ipv6=true;replicaSet=xq;safe=true&lt;/p&gt;


&lt;p&gt;System.Net.Sockets.SocketException: No connection could be made&lt;br/&gt;
because the target machine actively refused it &lt;span class=&quot;error&quot;&gt;&amp;#91;::1&amp;#93;&lt;/span&gt;:40000&lt;br/&gt;
  at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,&lt;br/&gt;
SocketAddress socketAddress)&lt;br/&gt;
  at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)&lt;br/&gt;
  at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)&lt;br/&gt;
  at MongoDB.Driver.Internal.MongoConnection.Open() in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line&lt;br/&gt;
266&lt;br/&gt;
  at MongoDB.Driver.Internal.MongoConnection.GetNetworkStream() in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line&lt;br/&gt;
409&lt;br/&gt;
  at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage&lt;br/&gt;
message, SafeMode safeMode) in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line&lt;br/&gt;
403&lt;br/&gt;
  at MongoDB.Driver.Internal.MongoConnection.RunCommand(String&lt;br/&gt;
collectionName, QueryFlags queryFlags, CommandDocument command) in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line&lt;br/&gt;
296&lt;br/&gt;
  at MongoDB.Driver.MongoServerInstance.Connect(Boolean slaveOk) in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoServerInstance.cs:line&lt;br/&gt;
254&lt;br/&gt;
  at MongoDB.Driver.Internal.ReplicaSetConnector.ConnectWorkItem(Object&lt;br/&gt;
argsObject) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\ReplicaSetConnector.cs:line&lt;br/&gt;
100&lt;br/&gt;
  &amp;#8212; End of inner exception stack trace &amp;#8212;&lt;br/&gt;
  at MongoDB.Driver.Internal.ReplicaSetConnector.Connect(TimeSpan&lt;br/&gt;
timeout) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\ReplicaSetConnector.cs:line&lt;br/&gt;
87&lt;br/&gt;
  at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout) in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoServer.cs:line&lt;br/&gt;
435&lt;br/&gt;
  at MongoDB.Driver.MongoServer.Connect() in&lt;br/&gt;
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoServer.cs:line&lt;br/&gt;
415&lt;br/&gt;
  at IQ.IR.Data.Configuration.GetMongoDB(String connection) in&lt;br/&gt;
C:\Dev\XQ.Service\IQ.IR.Data\Configuration.cs:line 52&lt;/p&gt;

&lt;p&gt;This is the code...&lt;/p&gt;

&lt;p&gt;        static MongoDatabase GetMongoDB(string connection)&lt;br/&gt;
        {&lt;br/&gt;
            const string testBox = &quot;xxxx&quot;;&lt;br/&gt;
            var addr1 = new MongoServerAddress(testBox, 40000);&lt;br/&gt;
            var addr2 = new MongoServerAddress(testBox, 40001);&lt;br/&gt;
            var addr3 = new MongoServerAddress(testBox, 40002);&lt;br/&gt;
            MongoUrlBuilder url = new MongoUrlBuilder&lt;br/&gt;
                          {&lt;br/&gt;
                              IPv6 = true,&lt;br/&gt;
                              SafeMode = SafeMode.True,&lt;br/&gt;
                              Servers = new List&amp;lt;MongoServerAddress&amp;gt; &lt;/p&gt;
{
addr1, addr2, addr3 }
&lt;p&gt;,&lt;br/&gt;
                              ConnectionMode = ConnectionMode.ReplicaSet,&lt;br/&gt;
                              ReplicaSetName = &quot;xq&quot;&lt;br/&gt;
                          };&lt;/p&gt;

&lt;p&gt;            try&lt;/p&gt;
            {
                var mongo = MongoServer.Create(url.ToMongoUrl());
                mongo.Connect();
                return mongo.GetDatabase(&quot;xq&quot;);
            }
&lt;p&gt;            catch (Exception ex)&lt;br/&gt;
            {&lt;br/&gt;
                throw new Exception(string.Format(&quot;&amp;lt;&amp;lt;&lt;/p&gt;
{0}
&lt;p&gt;&amp;gt;&amp;gt; &lt;/p&gt;
{1}
&lt;p&gt;&quot;,&lt;br/&gt;
url.ToMongoUrl(), ex));&lt;br/&gt;
            }&lt;br/&gt;
        }&lt;/p&gt;

&lt;p&gt;I put a test in to see if the Host value resolves to an IP and it does (IPv6).&lt;/p&gt;</description>
                <environment>Running on Azure connecting to a local VM running 3 mongod.exe as replica sets </environment>
        <key id="18634">CSHARP-255</key>
            <summary>SocketException on MongoServer.Connect()</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="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="woaksie">John Woakes</reporter>
                        <labels>
                            <label>connection</label>
                    </labels>
                <created>Fri, 24 Jun 2011 00:13:36 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:42 +0000</updated>
                            <resolved>Mon, 4 Jul 2011 15:59:54 +0000</resolved>
                                    <version>1.1</version>
                                    <fixVersion>1.1</fixVersion>
                    <fixVersion>1.2</fixVersion>
                                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="40621" author="woaksie" created="Tue, 5 Jul 2011 15:56:29 +0000"  >&lt;p&gt;In my case IPv6 is the only option. I had ipv6=true and used ipv6 addresses everywhere and it didn&apos;t work. But I am actually happier using machine names as they are less likely to change.&lt;/p&gt;</comment>
                            <comment id="40589" author="rstam" created="Tue, 5 Jul 2011 14:16:16 +0000"  >&lt;p&gt;I think you will have to be consistent and use either IPv4 or IPv6 addresses throughout. And your driver connection string should have ipv6=true if you are using IPv6 addresses.&lt;/p&gt;</comment>
                            <comment id="40457" author="woaksie" created="Mon, 4 Jul 2011 16:07:59 +0000"  >&lt;p&gt;I guess the question is should it work with IP addresses? I only tested IPv6 but I wonder if a regular IP address would work...&lt;/p&gt;</comment>
                            <comment id="40455" author="rstam" created="Mon, 4 Jul 2011 15:59:34 +0000"  >&lt;p&gt;Thanks for letting us know, and I&apos;m glad it&apos;s working for you now.&lt;/p&gt;</comment>
                            <comment id="40453" author="woaksie" created="Mon, 4 Jul 2011 15:52:30 +0000"  >&lt;p&gt;It is fully working now. When initializing the replica sets you have to use host names, not localhost or IPv6 addresses. &lt;/p&gt;</comment>
                            <comment id="39552" author="woaksie" created="Tue, 28 Jun 2011 18:39:59 +0000"  >&lt;p&gt;I think I know what is happening here. When I set up the test server running mongod I set up 3 instances on the same machine and configured replication using localhost:port. If I look at rs.status() I see the names in members are localhost:port. I think the driver picks these up and tries to use them. I am in the process of trying to fix this or start afresh. I will let you know how I get on.&lt;/p&gt;</comment>
                            <comment id="39415" author="woaksie" created="Mon, 27 Jun 2011 20:07:59 +0000"  >&lt;p&gt;I added a call to this just before the failing connect&lt;/p&gt;

&lt;p&gt;        private static void OutputServerDetails(MongoServer mongo)&lt;br/&gt;
        {&lt;br/&gt;
            var result = string.Empty;&lt;br/&gt;
            foreach (var address in mongo.Settings.Servers)&lt;br/&gt;
            {&lt;br/&gt;
                result += string.Format(&quot;&lt;/p&gt;
{0}
&lt;p&gt; &lt;/p&gt;
{1}
&lt;p&gt; &quot;, address.Host, address.Port);&lt;br/&gt;
                try&lt;/p&gt;
                {
                    result += address.ToIPEndPoint(AddressFamily.InterNetworkV6);
                }
&lt;p&gt;                catch (Exception ex)&lt;/p&gt;
                {
                    result += ex.Message;
                }
&lt;p&gt;                result += &quot;; &quot;;&lt;br/&gt;
            }&lt;br/&gt;
            throw new Exception(result);&lt;br/&gt;
        }&lt;/p&gt;

&lt;p&gt;and got &lt;/p&gt;

&lt;p&gt;System.Exception: IQ-xxxxx002.iQmetrixHO.local 40000 &lt;span class=&quot;error&quot;&gt;&amp;#91;2a01:111:f102:122:cc28:398f:262c:3333&amp;#93;&lt;/span&gt;:40000; IQ-xxxxx002.iQmetrixHO.local 40001 &lt;span class=&quot;error&quot;&gt;&amp;#91;2a01:111:f102:122:cc28:398f:262c:3333&amp;#93;&lt;/span&gt;:40001; IQ-xxxxx002.iQmetrixHO.local 40002 &lt;span class=&quot;error&quot;&gt;&amp;#91;2a01:111:f102:122:cc28:398f:262c:3333&amp;#93;&lt;/span&gt;:40002; &lt;/p&gt;

&lt;p&gt;so it looks like the host name resolves...&lt;/p&gt;</comment>
                            <comment id="39379" author="woaksie" created="Mon, 27 Jun 2011 17:51:05 +0000"  >&lt;p&gt;I had it working with v1.0... &lt;/p&gt;

&lt;p&gt;We are running the client in Microsoft&apos;s Azure cloud platform and the mongod is running in our local data center. I will continue digging to see if I can provide more information.&lt;/p&gt;</comment>
                            <comment id="39377" author="rstam" created="Mon, 27 Jun 2011 17:47:07 +0000"  >&lt;p&gt;Odd then that the error message had &quot;&lt;span class=&quot;error&quot;&gt;&amp;#91;::1&amp;#93;&lt;/span&gt;:40000&quot; as the address...&lt;/p&gt;

&lt;p&gt;If the client and server are in different data centers, could it be a firewall issue?&lt;/p&gt;</comment>
                            <comment id="39353" author="woaksie" created="Mon, 27 Jun 2011 16:14:00 +0000"  >&lt;p&gt;I am not running the client and mongod on the same machine. The xxxx machine is in a different data center. Using localhost would not work. If I do a System.Net.Dns.GetHostAddresses(&quot;xxxx&quot;) from the client I get one valid IPv6 address (not localhost).&lt;/p&gt;

&lt;p&gt;I am running my mongod with the --ipv6 flag.&lt;/p&gt;</comment>
                            <comment id="39020" author="rstam" created="Fri, 24 Jun 2011 03:50:11 +0000"  >&lt;p&gt;I also get the same results with either the 1.0 or the 1.1 version of the driver.&lt;/p&gt;</comment>
                            <comment id="39019" author="rstam" created="Fri, 24 Jun 2011 03:47:31 +0000"  >&lt;p&gt;FYI, I set up a 3 member replica set and was able to connect to it using essentially the same connection string as yours:&lt;/p&gt;

&lt;p&gt;    var server = MongoServer.Create(&quot;mongodb://localhost:10001,localhost:10002,localhost:10003/?safe=true;replicaset=myset;ipv6=true&quot;);&lt;/p&gt;

&lt;p&gt;Again, I could only connect if I had used --ipv6 when starting mongod.&lt;/p&gt;</comment>
                            <comment id="39018" author="rstam" created="Fri, 24 Jun 2011 03:43:37 +0000"  >&lt;p&gt;Not that it necessarily explains your exception, but when I launch mongod without -ipv6 and then put &quot;ipv6=true&quot; in the client connection string I do get the same exception you are reporting.&lt;/p&gt;</comment>
                            <comment id="39014" author="rstam" created="Fri, 24 Jun 2011 03:27:40 +0000"  >&lt;p&gt;The IPv6 address &lt;span class=&quot;error&quot;&gt;&amp;#91;::1&amp;#93;&lt;/span&gt; is localhost, so I&apos;m assuming that even though you are using the host name &quot;xxxx&quot; your client and mongod servers are all running on the same box.&lt;/p&gt;

&lt;p&gt;A connection refused exception implies that the host name was resolved correctly, but that there was no server listening on that host/port combination.&lt;/p&gt;

&lt;p&gt;Did you launch mongod with the --ipv6 command line parameter? mongod won&apos;t listen on IPv6 addresses unless you ask it to.&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|hrh8s7:</customfieldvalue>

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