<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:59:57 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>[CXX-676] Cannot connect to replica set using C++ driver</title>
                <link>https://jira.mongodb.org/browse/CXX-676</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;When using legacy C++ driver, cannot connect to replica set servers. Although I can connect to every member separately with no problem. When multiple servers are specified in connection string, empty pointer is returned from cs.connect().&lt;/p&gt;

&lt;p&gt;Code snippet:&lt;br/&gt;
#include &amp;lt;mongo/client/dbclient.h&amp;gt; &lt;br/&gt;
#include &amp;lt;mongo/client/options.h&amp;gt;&lt;br/&gt;
#include &amp;lt;mongo/client/init.h&amp;gt;&lt;br/&gt;
#include &amp;lt;mongo/bson/bson.h&amp;gt;&lt;br/&gt;
#include &amp;lt;iostream&amp;gt;&lt;br/&gt;
#include &amp;lt;memory&amp;gt;&lt;br/&gt;
#include &amp;lt;iostream&amp;gt;&lt;/p&gt;

&lt;p&gt;using namespace mongo;&lt;br/&gt;
using namespace std;&lt;/p&gt;

&lt;p&gt;int main() {&lt;br/&gt;
  string rsName = &quot;myProductionSet&quot;;&lt;br/&gt;
  string err;&lt;br/&gt;
  bool master;&lt;/p&gt;

&lt;p&gt;  client::Options opt;&lt;br/&gt;
  client::initialize(opt);&lt;br/&gt;
  ConnectionString cs = ConnectionString::parse(&quot;mongodb://&lt;span class=&quot;error&quot;&gt;&amp;#91;host1&amp;#93;&lt;/span&gt;:27017,&lt;span class=&quot;error&quot;&gt;&amp;#91;host2&amp;#93;&lt;/span&gt;:27117/?replicaSet=myProductionSet&quot;,err); &lt;/p&gt;

&lt;p&gt;  DBClientReplicaSet* client = static_cast&amp;lt;DBClientReplicaSet*&amp;gt;(cs.connect(err));&lt;br/&gt;
  if(!client) &lt;/p&gt;
{
    cout &amp;lt;&amp;lt; &quot;Empty pointer&quot; &amp;lt;&amp;lt; endl;
  }
&lt;p&gt;   &lt;/p&gt;

&lt;p&gt;  if(client-&amp;gt;isMaster(master))&lt;br/&gt;
    std::cout &amp;lt;&amp;lt; &quot;OK&quot; &amp;lt;&amp;lt; std::endl;&lt;br/&gt;
  else&lt;br/&gt;
    std::cout &amp;lt;&amp;lt; &quot;ERR&quot; &amp;lt;&amp;lt; std::endl;&lt;/p&gt;

&lt;p&gt;  return 0;&lt;br/&gt;
}&lt;/p&gt;

</description>
                <environment></environment>
        <key id="231299">CXX-676</key>
            <summary>Cannot connect to replica set using C++ driver</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="5">Cannot Reproduce</resolution>
                                        <assignee username="adam.midvidy">Adam Midvidy</assignee>
                                    <reporter username="peter123">Peter </reporter>
                        <labels>
                            <label>legacy-cxx</label>
                    </labels>
                <created>Thu, 24 Sep 2015 13:16:49 +0000</created>
                <updated>Thu, 29 Oct 2015 19:50:56 +0000</updated>
                            <resolved>Fri, 16 Oct 2015 15:12:10 +0000</resolved>
                                    <version>legacy-1.0.5</version>
                                                    <component>Release</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1074561" author="adam.midvidy" created="Thu, 29 Oct 2015 19:50:56 +0000"  >&lt;p&gt;Hi Peter,&lt;/p&gt;

&lt;p&gt;Did you check that the client machine (running the C++ driver) was able to resolve the hostnames of the replica set nodes? This can be a problem when running on AWS, as the seedlist returned by the server to the driver will return the internal (AWS only) DNS address, which will cause the driver to fail to connect. &lt;/p&gt;

&lt;p&gt;In the replica set documentation, we remind users to ensure that &quot;each member of a replica set is accessible by way of resolvable DNS or hostnames.&quot; (&lt;a href=&quot;https://docs.mongodb.org/manual/tutorial/deploy-replica-set/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.mongodb.org/manual/tutorial/deploy-replica-set/&lt;/a&gt;). Nonetheless, as this seems like a MongoDB issue (as opposed to a C++ driver issue) I would recommend that you follow up on mongodb-user if you have further questions.&lt;/p&gt;

&lt;p&gt;Adam&lt;/p&gt;</comment>
                            <comment id="1071546" author="peter123" created="Tue, 27 Oct 2015 14:21:00 +0000"  >&lt;p&gt;Looks, like I found the problem - it is described here:&lt;br/&gt;
&lt;a href=&quot;https://www.amido.com/mongodb-unable-to-connect-to-a-member-of-the-replica-set-matching-the-read-preference-primary/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://www.amido.com/mongodb-unable-to-connect-to-a-member-of-the-replica-set-matching-the-read-preference-primary/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I replicated the steps - namely reconfigured members of replica set not to be identified by hostnames (although DNS was setup and machines were able to communicate using these names), but now containig full host identification: &lt;span class=&quot;error&quot;&gt;&amp;#91;my service&amp;#93;&lt;/span&gt;.cloudapp.net:&lt;span class=&quot;error&quot;&gt;&amp;#91;port&amp;#93;&lt;/span&gt; and now the source code works.&lt;/p&gt;

&lt;p&gt;Would that be possible to add this information to docs somewhere?&lt;/p&gt;

&lt;p&gt;Thanks for your time.&lt;/p&gt;</comment>
                            <comment id="1071305" author="peter123" created="Tue, 27 Oct 2015 08:18:34 +0000"  >&lt;p&gt;Hi Adam,&lt;br/&gt;
sorry for late answer. I have new information : upgraded server to version 3.0.7, updated and recompiled C++ driver version 1.0.6. &lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04), using -std=c++11 and -g flags for source compilation&lt;/li&gt;
	&lt;li&gt;scons --dbg=on --c++11=on --sharedclient=SHAREDCLIENT install&lt;/li&gt;
	&lt;li&gt;source code mentioned above, when specified 3 servers in connection string, connect returns empty pointer&lt;/li&gt;
	&lt;li&gt;3 mongod servers running as replica set with 1 primary&lt;/li&gt;
	&lt;li&gt;replica set is normally running, when inserting data to primary, data is replicated to secondary nodes as expected&lt;/li&gt;
	&lt;li&gt;when connecting only to one node (no replica set in connection string specified), connection works as expected&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I also attached configuration and log from mongo server.&lt;/p&gt;</comment>
                            <comment id="1062875" author="adam.midvidy" created="Fri, 16 Oct 2015 15:11:54 +0000"  >&lt;p&gt;Hi Peter,&lt;/p&gt;

&lt;p&gt;I am going to close this issue out. If you are still having trouble, please re-open it.&lt;/p&gt;</comment>
                            <comment id="1049957" author="adam.midvidy" created="Fri, 2 Oct 2015 15:54:19 +0000"  >&lt;p&gt;Also, I noticed you are building the driver with C+&lt;ins&gt;11. Are you building your test executable with C&lt;/ins&gt;+11 as well?&lt;/p&gt;</comment>
                            <comment id="1049953" author="adam.midvidy" created="Fri, 2 Oct 2015 15:53:14 +0000"  >&lt;p&gt;Hi Peter,&lt;/p&gt;

&lt;p&gt;That error would be hit if none of the replica set nodes are reachable at the time the replica set connection his created. Can you elaborate on the configuration of your replica set? What is the # of servers and what version of MongoDB are they running?&lt;/p&gt;

&lt;p&gt;Also, can you attach MongoDB logs for when this connection failure occurs?&lt;/p&gt;

&lt;p&gt;Best,&lt;br/&gt;
Adam&lt;/p&gt;</comment>
                            <comment id="1045878" author="peter123" created="Tue, 29 Sep 2015 09:16:24 +0000"  >&lt;p&gt;Hi, the string says: &quot;connect failed to replica set &lt;span class=&quot;error&quot;&gt;&amp;#91;replica set name&amp;#93;&lt;/span&gt;/&lt;span class=&quot;error&quot;&gt;&amp;#91;host1&amp;#93;&lt;/span&gt;:&lt;span class=&quot;error&quot;&gt;&amp;#91;port1&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;host2&amp;#93;&lt;/span&gt;:&lt;span class=&quot;error&quot;&gt;&amp;#91;port2&amp;#93;&lt;/span&gt;,&lt;span class=&quot;error&quot;&gt;&amp;#91;host3&amp;#93;&lt;/span&gt;:&lt;span class=&quot;error&quot;&gt;&amp;#91;port3&amp;#93;&lt;/span&gt;&quot;&lt;br/&gt;
Maybe I also should add, that virtual machines running mongo instances are deployed in Azure.&lt;/p&gt;</comment>
                            <comment id="1045334" author="adam.midvidy" created="Mon, 28 Sep 2015 19:44:59 +0000"  >&lt;p&gt;Also, what are the contents of the string &apos;err&apos; after connection fails?&lt;/p&gt;</comment>
                            <comment id="1044605" author="peter123" created="Mon, 28 Sep 2015 07:12:31 +0000"  >&lt;p&gt;Authentication is not enabled, I&apos;m waiting for this basic scenario to work first.&lt;/p&gt;</comment>
                            <comment id="1043486" author="adam.midvidy" created="Fri, 25 Sep 2015 15:19:52 +0000"  >&lt;p&gt;Hi peto2468@hotmail.com, are you running with auth enabled on your cluster?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="95689" name="mongod.conf" size="873" author="peter123" created="Tue, 27 Oct 2015 08:20:16 +0000"/>
                            <attachment id="95690" name="mongod.log" size="1036" author="peter123" created="Tue, 27 Oct 2015 08:20:16 +0000"/>
                            <attachment id="95691" name="rsStatus.txt" size="1365" author="peter123" created="Tue, 27 Oct 2015 08:20:16 +0000"/>
                    </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|hre4rb:</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>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="688">Platform A (10/09/15)</customfieldvalue>
    <customfieldvalue id="722">Platform B (10/30/15)</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>