[CSHARP-1239] MongoClient misinterprets connection settings Created: 12/Apr/15  Updated: 05/Apr/19  Resolved: 04/Apr/16

Status: Closed
Project: C# Driver
Component/s: API, Connectivity
Affects Version/s: 2.0
Fix Version/s: None

Type: Task Priority: Blocker - P1
Reporter: Lukas Wagner Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: connection, question
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Client: Linux Mint 17.1 x86_64
Server: CentOS 7 x86_64
Mongod: db version v2.6.9
2015-04-12T07:34:10.623-0400 git version: df313bc75aa94d192330cb92756fc486ea604e64


Attachments: File Code.cs     File Code_v2.cs     HTML File Exception     HTML File Exception_v2    

 Description   

The default MongoClient Constructor tries to connect to Unspecified/localhost:27017 instead of localhost:27017. Even if the constructor gets either MongoClientSettings or a connection string it does that strange thing of adding Unspecified/ as a prefix to the host name.



 Comments   
Comment by Lukas Wagner [ 16/Apr/15 ]

Hi Craig,

it's in all tests the same with an IP Address added (127.0.0.1 as well as the external IP address of the adapter).

This is the output of 'mono --version':
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4ubuntu1.1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

I'm using monodevelop (the opt version which also has the dlang tools aboard, not from the official repos) and I set the project up to be using 'mono/.Net 4.5'.
Hope that helps
Lukas

Comment by Craig Wilson [ 16/Apr/15 ]

Have not had a chance yet Lukas... However, I have another question and a request:

  • What version of Mono are you using?
  • Could you try to use a fully qualified domain name or IP address instead of "localhost"?

Craig

Comment by Lukas Wagner [ 16/Apr/15 ]

Were you able to reproduce? If not I can give you a virtual machine with the error.

Comment by Lukas Wagner [ 14/Apr/15 ]

Thanks a lot
Just use the code I provided here and the 2.0.0 drivers from the GitHub release page.

Comment by Craig Wilson [ 14/Apr/15 ]

Lukas,

I'm trying to reproduce this. We test on MacOSX and it's not a problem there. I'll fire up a linux box and see if I can reproduce.

Craig

Comment by Lukas Wagner [ 14/Apr/15 ]

I think the heading of this Report is wrong it shoud have something to do with "No route to host for C# driver on Linux".

Comment by Lukas Wagner [ 14/Apr/15 ]

It's the same on CentOS 7 (Fresh and clean install, mongodb on localhost).
If it doesn't work for CentOS 7 then I'm sure it doesn't work for the rest of the Red Hat Linuxes.
If it doesn't work on Linux Mint, you can be sure it doesn't work on Ubuntu and almost be sure it doesn't work on Debian.
Now please test it, it is reproducable. Unfortunately Network tracing does not work for me, not sure why...

Comment by Lukas Wagner [ 14/Apr/15 ]

I can even connect with java and c++. It has to be something about the c# driver.

Comment by Lukas Wagner [ 13/Apr/15 ]

I think I have to rebuild the mongo driver with the d:TRACE compiler option? Any tips?

Comment by Lukas Wagner [ 13/Apr/15 ]

I learned everything there is about tracing at msdn, but it just doesn't work. I defined he sources and I defined an output and I added the compiler option. I can't see any output.
I made a few more tests. I reinstalled mongod on localhost. I can still connect with robomongo and with mongo. And I still get "System.Net.Sockets.SocketException: Connection refused"

Comment by Lukas Wagner [ 12/Apr/15 ]

I actually have no Idea how to trace C#, I recently began using it. I will try and find out how it works. For now I found out hat there is the possibility to create an app.config file. I pasted the code in there, cleaned and recompiled. Based upon how this piece of config file looks, I would expect there to be a network.log either in the directory I'm running the program from or in the directory the executable resides in. However. there's nothing like that.

Comment by Craig Wilson [ 12/Apr/15 ]

Lukas,

I'm not sure what to say. I can run your code without failure. In fact, this is almost exactly how our entire test suite runs. There is going to be some setting somewhere that is causing this issue. If you could, please turn on network tracing, particularly the System.Net.Sockets one and maybe we can see inside the trace what is going on down in the network stack.

Craig

Comment by Lukas Wagner [ 12/Apr/15 ]

The same thing happens here Code_v2.cs. I can connect to this server via robomongo. It is running whithin a virtual machine

Comment by Craig Wilson [ 12/Apr/15 ]

Hi Lukas,

Sorry you are having trouble. The Unspecified/localhost:27017 is the output of a DnsEndPoint's ToString() method. What is really happening here is that we can't connect to localhost:27017. Are you sure the mongod process is running? The root exception is this:

System.Net.Sockets.SocketException: Connection refused.

This generally means that nothing is listening on localhost:27017.

Craig

Generated at Wed Feb 07 21:39:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.