gocql:无法创建会话:控制:无法连接到初始主机:登录失败

时间:2020-09-08 22:09:43

标签: cassandra gocql

cluster := gocql.NewCluster("1.2.3.4") //replace PublicIP with the IP addresses used by your cluster.
    cluster.Keyspace = "testkeyspace"
    cluster.Port = 9042

    cluster.DisableInitialHostLookup = true
    cluster.Authenticator = gocql.PasswordAuthenticator{Username: "test", Password: "testpwd"}
    cluster.ProtoVersion = 4 //replace the username and password fields with their real settings.
    cluster.Consistency = gocql.Quorum
    cluster.CQLVersion = "3.4.5"
    cluster.IgnorePeerAddr = true
    cluster.DefaultIdempotence = true
    cluster.Timeout = time.Second * 30
    cluster.ConnectTimeout = time.Second * 30
    session, err := cluster.CreateSession()
    //  session, err := ccfg.CreateSession()
    if err != nil {
        fmt.Println("error in session", err)
        return
    }
    defer session.Close()

我正在尝试连接并遇到问题。我能够与本地的cqlsh连接,并且gocql驱动程序失败,并显示以下错误消息,我具有go1.14和cassandra版本 cqlsh 5.0.1 | Cassandra 4.0.0.608 | CQL spec 3.4.5 | Native protocol v66

谢谢 扎克里

1 个答案:

答案 0 :(得分:0)

您发布的错误表明用户名或密码(或两者)不正确。您需要验证您是否在应用程序中输入了正确的凭据。干杯!