连接到 Cassandra 时"gocql: no response to connection startup within timeout"



尝试使用 gocql (Go: 1.8.3( 连接到 Cassandra (v 3.10.0(。这是错误

gocql:

无法拨号控制连接 [hostIP]:gocql:超时内对连接启动没有响应

panic: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(更多在这里(

我通过将cluster.DisableInitialHostLookup设置为 true 来解决它

最新更新