Reputation: 1225
Trying to connect to Cassandra (v 3.10.0) using gocql (Go: 1.8.3). Here is the error
gocql: unable to dial control conn [hostIP]: gocql: no response to connection startup within timeout
panic: gocql: unable to create session: control: unable to connect to initial hosts: gocql: no response to connection startup within timeout
here is the code...
func test() {
cluster := gocql.NewCluster("hostIP")
cluster.ProtoVersion = 4
cluster.Authenticator = gocql.PasswordAuthenticator{
Username: "<username>",
Password: "<password>",
}
cluster.Keyspace = "myspace"
cluster.Consistency = gocql.One
session, err := cluster.CreateSession()
if err != nil {
panic(err)
}
defer session.Close()
}
Can anyone point to what i could be missing ?
Upvotes: 2
Views: 4934
Reputation: 1225
Ok.. this is resolved. Posting in case this ends up helping someone
the first error was resolved by using ConnectTimeout
i.e. cluster.ConnectTimeout = time.Second * 10
then i got this error (found using gocql_debug
) - unable to dial "<internal VM IP>": dial tcp <internal VM IP>:9042: i/o timeout
(more here)
and i resolved it by setting cluster.DisableInitialHostLookup
to true
Upvotes: 12