连接到 Cassandra 时获取 "gocql: no response to connection startup within timeout"
Getting "gocql: no response to connection startup within timeout" while connecting to Cassandra
正在尝试使用 gocql(Go:1.8.3)连接到 Cassandra (v 3.10.0)。这是错误
gocql: 无法拨控conn [hostIP]: gocql: 超时无响应连接启动
恐慌:gocql:无法创建会话:控制:无法连接到初始主机:gocql:在超时内对连接启动没有响应
这是代码...
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()
}
谁能指出我可能遗漏了什么?
好的..这已经解决了。发帖以防最终帮助某人
第一个错误已通过使用 ConnectTimeout
解决,即 cluster.ConnectTimeout = time.Second * 10
然后我得到这个错误(使用 gocql_debug
发现)- unable to dial "<internal VM IP>": dial tcp <internal VM IP>:9042: i/o timeout
(更多 here)
我通过将 cluster.DisableInitialHostLookup
设置为 true
来解决它
正在尝试使用 gocql(Go:1.8.3)连接到 Cassandra (v 3.10.0)。这是错误
gocql: 无法拨控conn [hostIP]: gocql: 超时无响应连接启动
恐慌:gocql:无法创建会话:控制:无法连接到初始主机:gocql:在超时内对连接启动没有响应
这是代码...
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()
}
谁能指出我可能遗漏了什么?
好的..这已经解决了。发帖以防最终帮助某人
第一个错误已通过使用 ConnectTimeout
解决,即 cluster.ConnectTimeout = time.Second * 10
然后我得到这个错误(使用 gocql_debug
发现)- unable to dial "<internal VM IP>": dial tcp <internal VM IP>:9042: i/o timeout
(更多 here)
我通过将 cluster.DisableInitialHostLookup
设置为 true