尝试使用 gocql(Go:1.8.3)连接到 Cassandra(v 3.10.0)。这是错误
gocql: unable to dial control conn [hostIP]: gocql: 超时内连接启动无响应
panic :gocql:无法创建 session :控制:无法连接到初始主机: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
解决了它为真
关于go - 连接到 Cassandra 时获取 "gocql: no response to connection startup within timeout",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48575804/