<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52: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>[JAVA-440] errors when using localhost</title>
                <link>https://jira.mongodb.org/browse/JAVA-440</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Console output at the end.&lt;/p&gt;

&lt;p&gt;Running MongoDB locally, bound to localhost. The client keeps logging ReplicaSetStatus updates - that&apos;s problem #1.&lt;/p&gt;

&lt;p&gt;Then the client gets a connection refused from my NIC IP address - why is it trying to connect that way? Problem #2.&lt;/p&gt;

&lt;p&gt;Then, it thinks the replicaset master (there is no replica set, mind you) has moved from localhost to localhost, but thinks that server is down. That&apos;s problems #3 and #4.&lt;/p&gt;

&lt;p&gt;Then, it thinks the server is down from that point forward. My app will fail until I restart the app. Then this whole process starts over just a couple of minutes later.&lt;/p&gt;



&lt;p&gt;Running our app from Ant eventually gives me the following output:     &lt;/p&gt;

&lt;p&gt;     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:50:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen up: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Starting IDM Server on port 3002&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:55:19 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen down: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;kevinw-mbp/10.180.131.72:27017&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.DBPort._open(DBPort.java:206)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.DBPort.go(DBPort.java:94)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.DBPort.go(DBPort.java:75)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.DBPort.findOne(DBPort.java:129)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.DBPort.runCommand(DBPort.java:138)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:162)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.ReplicaSetStatus$Node.update(ReplicaSetStatus.java:156)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.ReplicaSetStatus.ensureMaster(ReplicaSetStatus.java:311)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:393)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; 	at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:292)&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:55:19 PM com.mongodb.DBTCPConnector _set&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Master switching from localhost:27017 to localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:55:29 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen down: localhost:27017&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; Sep 29, 2011 12:55:59 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
     &lt;span class=&quot;error&quot;&gt;&amp;#91;java&amp;#93;&lt;/span&gt; WARNING: Server seen down: localhost:27017&lt;/p&gt;</description>
                <environment>MacBookPro laptop running Mac OS X 10.6.8, MongoDB 2.0.0 from machomebrew, mongo-java-driver-2.6.3.jar</environment>
        <key id="23021">JAVA-440</key>
            <summary>errors when using localhost</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="antoine">Antoine Girbal</assignee>
                                    <reporter username="kevwil">Kevin Williams</reporter>
                        <labels>
                            <label>down</label>
                            <label>localhost</label>
                            <label>master</label>
                            <label>replicaset</label>
                    </labels>
                <created>Thu, 29 Sep 2011 19:10:21 +0000</created>
                <updated>Tue, 25 Jun 2013 16:49:44 +0000</updated>
                            <resolved>Wed, 9 Nov 2011 19:32:45 +0000</resolved>
                                    <version>2.6.3</version>
                                                    <component>Cluster Management</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="65740" author="kevwil" created="Wed, 9 Nov 2011 20:08:16 +0000"  >&lt;p&gt;No, the machine configuration actually had nothing to do with it - we get the same ReplicaSetStatus warnings on our servers if configured for one mongodb server. I was unaware of how the different constructor signatures would affect the runtime behavior, which gives a reproducible cause &amp;amp; effect.&lt;/p&gt;

&lt;p&gt;Thanks for the clarification, and thanks very much for the thorough investigation!&lt;/p&gt;

&lt;p&gt;Sorry you couldn&apos;t be here today, Scott. Kyle says &quot;hi&quot;.&lt;/p&gt;</comment>
                            <comment id="65724" author="scotthernandez" created="Wed, 9 Nov 2011 19:32:45 +0000"  >&lt;p&gt;It seems like this is really a machine configuration issue and not a driver issue. If there are other issues that have come from this discussion, please open new jira issues for them specifically.&lt;/p&gt;</comment>
                            <comment id="65720" author="scotthernandez" created="Wed, 9 Nov 2011 19:31:46 +0000"  >&lt;p&gt;The constructor that takes a list is exclusively for replica set connection mode. It is designed to take a seed list of servers to contact. A single item list is not a bad thing, and very useful in many cases of deployments.&lt;/p&gt;

&lt;p&gt;If you don&apos;t want that behavior, don&apos;t use the List&amp;lt;T&amp;gt; constructors, as Ryan has stated.&lt;/p&gt;

&lt;p&gt;We will be working to cleanup the MongoURI syntax so you can specify a mode to disable replica set connection mode when passing in a list, or to enable it when sending a single server address. Unfortunately these kinds of changes need to happen across all driver implementation (for all languages) for consistency and that takes more time.&lt;/p&gt;</comment>
                            <comment id="65715" author="rgnitz" created="Wed, 9 Nov 2011 19:16:29 +0000"  >&lt;p&gt;Scott (another driver engineer) is going to jump in here in  bit, but for now we are not going to change the behavior of Mongo(List&amp;lt;ServerAddress&amp;gt; addrs) to modify the behavior if there is only a single host because there is another constructor which takes a single ServerAddress. We very much appreciate your feedback and I will definitely update the javadocs to clarify the behavior of the various constructors.&lt;/p&gt;</comment>
                            <comment id="65708" author="kevwil" created="Wed, 9 Nov 2011 18:53:04 +0000"  >&lt;p&gt;While I&apos;m sure that everything you said is correct, I believe the localhost name resolution is a red herring for this issue, which turned out to be about passing a single-item list into the Mongo object constructor and having ReplicaSet connection errors as a result. I&apos;d like to steer the discussion back to that cause/effect now.&lt;/p&gt;

&lt;p&gt;My understanding is that if a List is passed to the Mongo constructor, it expects to manage connections to a ReplicaSet style of cluster, and attempts to track the master so that it knows where to send write operations to. It seems like there is some input validation or error checking that could be added here, to prevent a single-item List from operating is this clustered mode.&lt;/p&gt;

&lt;p&gt;You could certainly say &quot;You&apos;re holding it wrong.&quot; and perhaps send out a free bumper case to &quot;resolve&quot; the issue. I would prefer, if I may make a suggestion, to have the driver reject attempts to run with only one entry in a List, since the List-based constructor assumes this clustered mode of operation. Perhaps throw an exception, or at least log a stern warning about &quot;bad things are about to happen&quot;?&lt;/p&gt;</comment>
                            <comment id="65698" author="rgnitz" created="Wed, 9 Nov 2011 18:19:10 +0000"  >&lt;p&gt;Ok... I completely understand about keeping your network private. Are the local canonical and local addr the same as your internal address or are they the external address? If they are an external address, this is a problem.&lt;/p&gt;

&lt;p&gt;The local name is weird... most macs have something like kevinw-mbp.local (versus just kevinw-mbp). I am guessing this is related to you overriding the hostname.&lt;/p&gt;

&lt;p&gt;As of now, I am inclined to believe that there is something slightly off on your laptop. I am a bit hesitant about putting a localhost check/resolution override into the driver because oddly enough, some people override localhost.&lt;/p&gt;

&lt;p&gt;The easiest way around this is to use 127.0.0.1 instead of localhost for dev.&lt;/p&gt;

&lt;p&gt;Thoughts?&lt;/p&gt;</comment>
                            <comment id="65681" author="kevwil" created="Wed, 9 Nov 2011 17:10:21 +0000"  >&lt;p&gt;I might have used:&lt;/p&gt;

&lt;p&gt;sudo scutil --set HostName &amp;lt;putinyourhostname_or_fqdn_here&amp;gt;&lt;/p&gt;

&lt;p&gt;but I&apos;m not sure.&lt;/p&gt;</comment>
                            <comment id="65679" author="kevwil" created="Wed, 9 Nov 2011 17:06:58 +0000"  >&lt;p&gt;The uname response was:&lt;br/&gt;
Darwin kevinw-mbp 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386&lt;/p&gt;

&lt;p&gt;I&apos;m not comfortable divulging too much detail of our internal corporate network. I can say that the Test2 results were predictable localhost-style results except for the last one, the localAddr one.&lt;/p&gt;

&lt;p&gt;canonical: localhost - addr: 127.0.0.1 - name: localhost&lt;br/&gt;
canonical: localhost - addr: 0:0:0:0:0:0:0:1 - name: localhost&lt;br/&gt;
canonical: fe80:0:0:0:0:0:0:1%1 - addr: fe80:0:0:0:0:0:0:1%1 - name: localhost&lt;br/&gt;
local canonical: ##.##.##.## - local addr: ##.##.##.## - local name: kevinw-mbp&lt;/p&gt;

&lt;p&gt;I did do something a year or two ago in an attempt force my hostname, because our DHCP system was giving me a new host each day. I&apos;m not sure what that was exactly, but it was designed to only force the hostname - if it affected what InetAddress.getLocalHost() returns, that would be an unexpected side-effect.&lt;/p&gt;</comment>
                            <comment id="65587" author="rgnitz" created="Wed, 9 Nov 2011 01:14:10 +0000"  >&lt;p&gt;This is slightly strange...&lt;/p&gt;

&lt;p&gt;can you run the following commands:&lt;/p&gt;

&lt;p&gt;uname -a&lt;/p&gt;

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

&lt;p&gt;Also, I have attached Test2.java. This is just a simple Java program that diagnosis your network.&lt;/p&gt;

&lt;p&gt;Thanks for troubleshoot this with us...&lt;/p&gt;</comment>
                            <comment id="65566" author="kevwil" created="Tue, 8 Nov 2011 22:51:16 +0000"  >&lt;p&gt;I get &apos;connection refused&apos; errors because it&apos;s trying to connect to my public IP instead of 127.0.0.1 and I have my local MongoDB bound only to 127.0.0.1. I don&apos;t understand why it is trying to use my public IP when the code is specifying &apos;localhost&apos;.&lt;/p&gt;

&lt;p&gt;I can use &apos;localhost&apos; in our app code without getting this error, but I don&apos;t understand what the difference is.&lt;/p&gt;

&lt;p&gt;No proxy or vpn here.&lt;/p&gt;</comment>
                            <comment id="65556" author="rgnitz" created="Tue, 8 Nov 2011 22:23:02 +0000"  >&lt;p&gt;Ok... that part of your /etc/hosts file is the same as mine.&lt;/p&gt;

&lt;p&gt;I attached a test and I cannot recreate this issue.&lt;/p&gt;

&lt;p&gt;Can you try running the attached file and let me know what you see?&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

&lt;p&gt;Oh, do you have a proxy/vpn running on your machine?&lt;/p&gt;</comment>
                            <comment id="65555" author="rgnitz" created="Tue, 8 Nov 2011 22:19:22 +0000"  >&lt;p&gt;Tested against 2.7.0.&lt;/p&gt;</comment>
                            <comment id="65552" author="kevwil" created="Tue, 8 Nov 2011 22:00:56 +0000"  >&lt;p&gt;We use our local host files for a lot of internal things at work, so I can&apos;t post the whole thing.&lt;/p&gt;

&lt;p&gt;Here&apos;s the &apos;localhost&apos; portion of it.&lt;/p&gt;

&lt;p&gt;127.0.0.1   localhost&lt;br/&gt;
255.255.255.255 broadcasthost&lt;br/&gt;
::1         localhost&lt;br/&gt;
fe80::1%lo0 localhost&lt;/p&gt;</comment>
                            <comment id="65526" author="rgnitz" created="Tue, 8 Nov 2011 20:27:16 +0000"  >
&lt;p&gt;Glad you have a workaround. My workaround was to use 127.0.0.1 instead of localhost &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;Ok... can you post the following:&lt;/p&gt;

&lt;p&gt;cat /etc/hosts&lt;/p&gt;

&lt;p&gt;I had the same problem, but when I upgraded to a new Mac, the problem went away.&lt;/p&gt;

&lt;p&gt;Thx&lt;/p&gt;</comment>
                            <comment id="65521" author="kevwil" created="Tue, 8 Nov 2011 20:17:19 +0000"  >&lt;p&gt;If I detect a single-entry list before passing it in to the Mongo object constructor, I can pass the single entry instead. So, by being smart about it on my end I can avoid the error.&lt;/p&gt;

&lt;p&gt;If I do pass a single-entry list to the constructor, the error still happens.&lt;/p&gt;

&lt;p&gt;I have tried both the 2.6.5 driver and the new 2.7.0 driver, and this behavior seems to be the same for all three versions.&lt;/p&gt;</comment>
                            <comment id="65502" author="rgnitz" created="Tue, 8 Nov 2011 19:34:50 +0000"  >&lt;p&gt;Hi Kevin,&lt;/p&gt;

&lt;p&gt;Has this been resolved? Let us know so I can close this issue.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;-Ryan&lt;/p&gt;</comment>
                            <comment id="57671" author="kevwil" created="Thu, 29 Sep 2011 20:20:55 +0000"  >&lt;p&gt;OK, cool.&lt;/p&gt;

&lt;p&gt;I am using mongod 2.0.0 locally, by the way.&lt;/p&gt;

&lt;p&gt;Yes, localhost resolves to 127.0.0.1.&lt;/p&gt;

&lt;p&gt;We&apos;ll be upgrading the driver to 2.6.5 and the production servers from 1.8.2 to 2.0.0 after this release goes out, but for now I have to keep the 2.6.3 driver.&lt;/p&gt;

&lt;p&gt;Thanks for the help!&lt;/p&gt;</comment>
                            <comment id="57667" author="scotthernandez" created="Thu, 29 Sep 2011 20:11:06 +0000"  >&lt;p&gt;Yes, if you use the list constructor it will treat it as a replSet. &lt;/p&gt;

&lt;p&gt;With newer version of mongod (1.8+) we could detect that it isn&apos;t a replSet but not with earlier versions. It shouldn&apos;t cause problems though.&lt;/p&gt;

&lt;p&gt;Does localhost resolve to 127.0.0.1? I think on osx it might not in some cases. Also, you might want to upgrade to 2.6.5 as it has some related fixes.&lt;/p&gt;</comment>
                            <comment id="57664" author="kevwil" created="Thu, 29 Sep 2011 19:58:19 +0000"  >&lt;p&gt;I believe so. Our &apos;Repository&apos; classes have two constructors, one for a single server, and one for a list. The one that takes a list also sets up slaveOk() and WriteConcern.REPLICAS_SAVE.&lt;/p&gt;

&lt;p&gt;Thanks to your hint, it&apos;s a good bet that we&apos;re using the list but I only have one in my list, and that&apos;s causing all this replica-style behavior. Is that what you&apos;re thinking?&lt;/p&gt;</comment>
                            <comment id="57660" author="scotthernandez" created="Thu, 29 Sep 2011 19:49:34 +0000"  >&lt;p&gt;How are you constructing your Mongo instances? Are you supplying a list of one server?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="13774" name="Test.java" size="540" author="rn@deftlabs.com" created="Tue, 8 Nov 2011 22:19:22 +0000"/>
                            <attachment id="13775" name="Test2.java" size="610" author="rn@deftlabs.com" created="Wed, 9 Nov 2011 01:14:23 +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|hrhbof:</customfieldvalue>

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