<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:35:32 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>[GODRIVER-1039] mongo-go-driver fails with Server Selection Timeout when using MongoDB Atlas</title>
                <link>https://jira.mongodb.org/browse/GODRIVER-1039</link>
                <project id="14289" key="GODRIVER">Go Driver</project>
                    <description>&lt;p&gt;Go Version: 1.12.5&lt;/p&gt;

&lt;p&gt;I have this code which uses the node.js mongo driver&lt;/p&gt;

&lt;p&gt;    const MongoClient = require(&apos;mongodb&apos;).MongoClient;&lt;br/&gt;
    const uri = process.env.MONGO_HOST + &quot;dbname?retryWrites=true&quot;;&lt;br/&gt;
    const client = new MongoClient(uri, &lt;/p&gt;
{
        useNewUrlParser: true
    }
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;    client.connect(async (err) =&amp;gt; {&lt;br/&gt;
        if (err) &lt;/p&gt;
{
            throw err
        }
&lt;p&gt;        const collection = client.db(&quot;dbname&quot;).collection(&quot;collectionName&quot;);&lt;br/&gt;
        const cursor = collection.find()&lt;br/&gt;
        await cursor.forEach(console.log)&lt;br/&gt;
        // perform actions on the collection object&lt;br/&gt;
        client.close();&lt;br/&gt;
    });&lt;/p&gt;

&lt;p&gt;Which works fine.&lt;/p&gt;

&lt;p&gt;Using the `mongo-go-driver`, I do:&lt;/p&gt;


&lt;p&gt;	client, err := mongo.NewClient(options.Client().ApplyURI(os.Getenv(&quot;MONGO_HOST&quot;) + &quot;dbname?retryWrites=true&quot;)&lt;br/&gt;
	if err != nil &lt;/p&gt;
{
		panic(err)
	}&lt;br/&gt;
	ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)&lt;br/&gt;
	err = client.Connect(ctx)&lt;br/&gt;
	if err != nil {
		panic(err)
	}
&lt;p&gt;	database := client.Database(&quot;dbname&quot;)&lt;br/&gt;
    collection := database.Collection(&quot;collectionName&quot;)&lt;/p&gt;

&lt;p&gt;	res, err := collection.Find(context.Background(), bson.M{}, &amp;amp;options.FindOptions{&lt;br/&gt;
		Sort: bson.M&lt;/p&gt;
{
			&quot;priority&quot;: -1,
		}
&lt;p&gt;,&lt;br/&gt;
	})&lt;br/&gt;
	if err != nil &lt;/p&gt;
{
		panic(err)
	}&lt;br/&gt;
	results := make([]structs.ResponseType, 0)&lt;br/&gt;
	err = res.All(context.Background(), &amp;amp;results)&lt;br/&gt;
	if err != nil {
		panic(err)
	}

&lt;p&gt;But this panics with:&lt;/p&gt;

&lt;p&gt;    panic: server selection error: server selection timeout&lt;br/&gt;
    current topology: Type: ReplicaSetNoPrimary&lt;/p&gt;

&lt;p&gt;I am not running this inside a container/docker.&lt;/p&gt;</description>
                <environment></environment>
        <key id="766321">GODRIVER-1039</key>
            <summary>mongo-go-driver fails with Server Selection Timeout when using MongoDB Atlas</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="AyushG3112">Ayush Gupta [X]</reporter>
                        <labels>
                    </labels>
                <created>Mon, 13 May 2019 12:09:07 +0000</created>
                <updated>Mon, 13 May 2019 16:21:32 +0000</updated>
                            <resolved>Mon, 13 May 2019 16:21:17 +0000</resolved>
                                    <version>1.0.1</version>
                                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="2244174" author="ayushg3112" created="Mon, 13 May 2019 13:07:38 +0000"  >&lt;p&gt;I just used dep and froze on v1.0.1 and it works, so something broke after that&lt;/p&gt;</comment>
                            <comment id="2244112" author="ayushg3112" created="Mon, 13 May 2019 12:11:56 +0000"  >&lt;p&gt;Version&lt;/p&gt;

&lt;p&gt;var Driver = &quot;v1.1.0+prerelease&quot;&lt;/p&gt;</comment>
                            <comment id="2244110" author="ayushg3112" created="Mon, 13 May 2019 12:10:28 +0000"  >&lt;p&gt;A formatted version of the issue/question can be found at &lt;a href=&quot;https://stackoverflow.com/questions/56111999/mongo-go-driver-fails-with-server-selection-timeout-when-using-mongodb-atlas&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://stackoverflow.com/questions/56111999/mongo-go-driver-fails-with-server-selection-timeout-when-using-mongodb-atlas&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="763455">GODRIVER-1032</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <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|huokov:</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>