Closed lefth closed 6 years ago
Not sure if this is related, but in Perl 5, there are issues with localhost DNS resolution -- you can get the IPv6 address resolved first and if mongod isn't running with an IPv6 address, you get this sort of error. The workaround is to prefer IPv4 DNS resolution for localhost. See https://github.com/mongodb/mongo-perl-driver/blob/master/lib/MongoDB/_Link.pm#L168-L183
We've also considered implementing Happy Eyeballs but haven't gotten around to it.
@xdg That seems to be it. By connecting to 127.0.0.1 instead of localhost, the tests run successfully. Would it be worth changing the example script to connect to "mongodb://127.0.0.1" instead of "mongodb://"? I know you want the simplest URL you can have, but it seems like a pretty big deal that the script won't connect on Windows 10. People will assume the driver just doesn't work.
Of course, if you implement Happy Eyeballs, you could re-simplify the demo script URL.
I'll try to find a way to do this. Btw, by 'the example script' you mean the script described in the README? There, I can also make a note about the reason why to do that.
@MARTIMM That's right, since the script in the README is what shows up when viewing this project in Github. I'd be glad if you could make some change or note that would save future users from tripping over this.
Btw, on my system (Linux) I've got this file /etc/hosts which have these entries amongst others
127.0.0.1 localhost
::1 localhost6
Now, localhost6 would always use the ipv6 stack and localhost the ipv4. Isn't that possible on windows? I know that is a bit more complex than this. E.g. it can look for DNS only and not in local files
added the message in the synopsis
Thanks for your recent note in the readme. I believe 'mongodb://::1' should be 'mongodb://[::1]'. (There's an error without the brackets on both Windows and Linux.)
On Sat, Sep 23, 2017 at 3:06 AM Marcel Timmerman notifications@github.com wrote:
added the message in the synopsis
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MARTIMM/mongo-perl6-driver/issues/25#issuecomment-331534683, or mute the thread https://github.com/notifications/unsubscribe-auth/ACDk45XHqv3Ocpyglt2W_jmHMayo8aMbks5slAVPgaJpZM4Pe1Fb .
You're quite right. I hadn't the foggiest idea back then, It was even not parsable by the Uri module. A few other things needed to be done in the Server and Socket module. This works now, so mongodb://[::1]:27017
for example, should work. I can also change the message to show some choices. Somewhere a note must also be made in the Client pod doc.
Also important to know is when a connection is tried over ipv4 and it fails, it tries to connect over ipv6.
Everything is done. Maybe later connections over ipv4/ipv6 will be tried in parallel.
Using mongodb 3.4.9 64-bit on Windows 10, the mongo shell can connect, Python can connect, but the test script on the mongo-perl6-driver homepage cannot connect. The exception is:
Could not connect socket: No connection could be made because the target machine actively refused it. in submethod BUILD at D:\rakudo\share\perl6\site\sources\F06B1BC1B4DA64A475CC2619F99FBDE5AC0E1F5B (MongoDB::Server::Socket) line 26 in method get-socket at D:\rakudo\share\perl6\site\sources\4F88D22071E3E320D8AAB5083BFC265C51014181 (MongoDB::Server) line 310 in method query at D:\rakudo\share\perl6\site\sources\BC879B4D25A6E436249E3A7F8D507366F886FFC8 (MongoDB::Wire) line 57 in method raw-query at D:\rakudo\share\perl6\site\sources\4F88D22071E3E320D8AAB5083BFC265C51014181 (MongoDB::Server) line 433 in submethod BUILD at D:\rakudo\share\perl6\site\sources\4F88D22071E3E320D8AAB5083BFC265C51014181 (MongoDB::Server) line 68 in block at D:\rakudo\share\perl6\site\sources\0D505187A8D30D605200BB70D053E9478E43DBB7 (MongoDB::Client) line 599 in method discover-servers at D:\rakudo\share\perl6\site\sources\0D505187A8D30D605200BB70D053E9478E43DBB7 (MongoDB::Client) line 569 in block at D:\rakudo\share\perl6\site\sources\0D505187A8D30D605200BB70D053E9478E43DBB7 (MongoDB::Client) line 130
My perl6 version is the 2017.09 release.