【问题标题】:Getting "gocql: no response to connection startup within timeout" while connecting to Cassandra连接到 Cassandra 时出现“gocql:超时内连接启动无响应”
【发布时间】:2018-02-02 14:04:01
【问题描述】:

尝试使用 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()
}

谁能指出我可能缺少什么?

【问题讨论】:

    标签: go cassandra gocql


    【解决方案1】:

    好的..这已解决。发帖以防万一这最终帮助了某人

    使用ConnectTimeoutcluster.ConnectTimeout = time.Second * 10 解决了第一个错误

    然后我收到此错误(使用 gocql_debug 找到)-unable to dial "&lt;internal VM IP&gt;": dial tcp &lt;internal VM IP&gt;:9042: i/o timeout(更多 here

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

    【讨论】:

      猜你喜欢
      • 2019-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      • 2015-10-30
      • 2023-04-04
      相关资源
      最近更新 更多