试图使用gocql连接Cassandra (v3.10.0) (Go: 1.8.3)。这是错误
gocql:无法拨号控制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()
}有人能指出我可能错过了什么吗?
发布于 2018-02-02 06:04:01
好的..。这个问题已经解决了。如果这件事最终会帮助别人
使用ConnectTimeout即cluster.ConnectTimeout = time.Second * 10解决了第一个错误
然后我得到了这个错误(使用gocql_debug) - unable to dial "<internal VM IP>": dial tcp <internal VM IP>:9042: i/o timeout (更多的这里)
我通过将cluster.DisableInitialHostLookup设置为true来解决这个问题
https://stackoverflow.com/questions/48575804
复制相似问题