连接到Cassandra时获取“gocql:在超时时间内没有对连接启动的响应”

连接到Cassandra时获取“gocql:在超时时间内没有对连接启动的响应”,go,cassandra,gocql,Go,Cassandra,Gocql,正在尝试使用gocql Go:1.8.3连接到Cassandra V3.10.0。这里是错误 gocql:无法拨号控制连接[hostIP]:gocql:在超时内没有对连接启动的响应 panic:gocql:无法创建会话:控件:无法连接到初始主机:gocql:在超时内没有对连接启动的响应 这是代码 func test() { cluster := gocql.NewCluster("hostIP") cluster.ProtoVersion = 4 cluster.Auth

正在尝试使用gocql Go:1.8.3连接到Cassandra V3.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_调试时发现了这个错误-无法拨号:拨号tcp:9042:i/o超时更多


我通过将cluster.DisableInitialHostLookup设置为true来解决这个问题。。这个问题已经解决了。以防最终帮助他人

第一个错误通过使用ConnectTimeout解决,即cluster.ConnectTimeout=time.Second*10

然后我在使用gocql_调试时发现了这个错误-无法拨号:拨号tcp:9042:i/o超时更多

我通过将cluster.DisableInitialHostLookup设置为true解决了这个问题