gocql: Cannot connect to scylla (Cassandra 2.2.8)

What version of Cassandra are you using?

cqlsh 5.0.1 | Cassandra 2.2.8 | CQL spec 3.3.1 | Native protocol v4 | Scylla version 1.7.4-0.20170726.ff643e3

What version of Gocql are you using?

Revision ce5020aabae349deda77bc1d559ef2300d3c93c5

What did you do?

use the following to spin up a local dev scylla instance

docker run --name some-scylla -p 9042:9042 -d scylladb/scylla --broadcast-address 127.0.0.1 --broadcast-rpc-address 127.0.0.1  

and then ran

package main

import (
	"fmt"

	"github.com/gocql/gocql"
)

func main() {
	cluster := gocql.NewCluster("127.0.0.1")
	_, err := cluster.CreateSession()
	if err != nil {
		panic(err)
	}
	fmt.Println("cassandra init done")
}

What did you expect to see?

Everything connect and initialize correctly.

What did you see instead?

Cassandra Configuration failed: no connections were made when creating the session

Describe your Cassandra cluster

  • output of nodetool status
[root@f779e8aea5c1 /]# nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns    Host ID                               Rack
UN  127.0.0.1  130.21 KB  256          ?       35a9b2db-a040-47bc-90b8-cdc6a56a17a6  rack1

Note: Non-system keyspaces don't have the same replication settings, effective ownership information is meaningless
  • output of SELECT peer, rpc_address FROM system.peers
 peer | rpc_address
------+-------------
  • rebuild your application with the gocql_debug tag and post the output
2017/10/05 16:38:18 gocql: Session.handleNodeUp: 127.0.0.1:9042
2017/10/05 16:38:20 unable to dial "172.17.0.2": dial tcp 172.17.0.2:9042: i/o timeout
2017/10/05 16:38:20 gocql: Session.handleNodeDown: 172.17.0.2:9042
2017/10/05 16:38:20 gocql: Session.handleNodeUp: 172.17.0.2:9042
2017/10/05 16:38:22 unable to dial "172.17.0.2": dial tcp 172.17.0.2:9042: i/o timeout
panic: no connections were made when creating the session

Related: https://github.com/gocql/gocql/issues/946

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

I had the same issue and fixed it by creating a docker network and adding a virtual interface to the host. The solution does not need to override or user default rout (0.0.0.0) for listen, broadcast and broadcast-rpc.

#add a virtual interface (os x) sudo ifconfig en0 inet 192.18.0.2 netmask 255.255.255.0 alias

#windows ifconfig eth0:1 10.0.0.11 netmask 255.255.255.0 up

#create docker subnetwork docker network create --subnet=192.18.0.0/24 skynet

#docker run scylla (you can always specify another ip for listen-address which need to be mapped to an alias on the host)

docker run --net skynet --ip 192.18.0.2 --name $NAME -p 192.18.0.2:9042:9042 -p 192.18.0.2:9160:9160 -d scylladb/scylla --overprovisioned 1

Clients will connect to the new adresse 192.18.0.2 i/o localhost

For those wondering where does 172.x.x.x come from, at startup scylla daemon creates system.local table and register container ip-address as listen-address(same for braodcast and broadcast-rpc). Clients retrieve those routes using cql and configure rpc (thrift to use those routes). if clients is containerized no issue as routing is handling by docker. But if clients is not containerized (eg client running on host) then it dials 172.x.x.x which does not exist on the host. I had this issue using scylladb with hadoop-gremlin for a janusgraph instance. Running a SparkGraphComputer fails.

I was able to fix this by having Scylla bind to all ports internally. Not sure what that means for related parties, but I think its a mac os docker networking issue with the scylla instance.

docker run --name some-scylla -p 9042:9042 -d scylladb/scylla --broadcast-address 127.0.0.1 --listen-address 0.0.0.0 --broadcast-rpc-address 127.0.0.1