-
Notifications
You must be signed in to change notification settings - Fork 31
1.1.0 - cannot connect with hostname #55
Comments
What operating system? I've noticed that I have problems on OS X with localhost since it doesn't resolve to 127.0.0.1 but only IPv6-addresses, and C* doesn't listen to those it seems. |
But weird it if works in 1.0.6. I'll have to see what's different between those versions. |
yes, OS X |
The only difference between v1.0 and v1.1 is that the latter doesn't specify IPv4 when looking up the IP for the hostname you give it (apart from a few other features that don't have to do with name resolution): # v1.0
# specifying AF_INET here
addrinfo = Socket.getaddrinfo(@host, @port, Socket::AF_INET, Socket::SOCK_STREAM)
_, port, _, ip, address_family, socket_type = addrinfo.first
@sockaddr = Socket.sockaddr_in(port, ip)
@io = Socket.new(address_family, socket_type, 0)
@io.connect_nonblock(@sockaddr)
# v1.1
unless @addrinfos
@connection_started_at = @clock.now
# not specifying AF_INET here
@addrinfos = @socket_impl.getaddrinfo(@host, @port, nil, Socket::SOCK_STREAM)
end
unless @io
_, port, _, ip, address_family, socket_type = @addrinfos.shift
@sockaddr = @socket_impl.sockaddr_in(port, ip)
@io = @socket_impl.new(address_family, socket_type, 0)
end
unless connected?
@io.connect_nonblock(@sockaddr)
@connected = true
@connected_promise.fulfill(self)
end could you run this in IRB and give me the output? (my output is inline): require 'socket'
Socket.getaddrinfo('localhost', 9042, Socket::AF_INET, Socket::SOCK_STREAM)
# => [["AF_INET", 9042, "127.0.0.1", "127.0.0.1", 2, 1, 6]]
Socket.getaddrinfo('localhost', 9042, nil, Socket::SOCK_STREAM)
# => [["AF_INET", 9042, "127.0.0.1", "127.0.0.1", 2, 1, 6], ["AF_INET6", 9042, "::1", "::1", 30, 1, 6], ["AF_INET6", 9042, "fe80::1%lo0", "fe80::1%lo0", 30, 1, 6]] What the v1.1 also does is that it tries all of the addresses returned, while v1.0 specified IPv4 and tried only the first address. However, it does not retry on a I've pushed up a branch called retry_connection_on_refused, try that and see if it works for you. |
yes, it seems my order is different and ipv6 is first |
Yes, the code on that branch works for me. |
I am using Mac OSX Mavericks, ruby 2 (2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]), Cassandra 1.2.10 with CQL 3. I was able to connect the first time, but I couldn't connect after that. I got the following error in irb and I get the same error when I run my ruby file (the following was implemented in irb):
I tried the exact same code on Ubuntu 12.04 and 13.10 with Cassandra 1.2.10 and 2.0.2 and it worked fine on all of them. |
@mhakeem thanks for reporting this too. I will push out a fix shortly. |
v1.1.1 has been released with this fix. |
works with 1.0.6, does not work with 1.1.0
error:
synchronous_client.rb:32:in `connect': Connection refused - connect(2) (Cql::Io::ConnectionError)
might be related to issue #50
however this is without other dependencies
same error with the use_resolv branch
connecting on ip address works
using ruby 1.9.3-p448
The text was updated successfully, but these errors were encountered: