如何解决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
谢谢 扎克里
解决方法
您发布的错误表明用户名或密码(或两者)不正确。您需要验证您是否在应用程序中输入了正确的凭据。干杯!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。