1 回答
TA贡献1878条经验 获得超4个赞
Cassandra 需要几秒钟来启动并开始接受连接;backend在准备好之前尝试连接。如果您backend在一小段延迟后启动(使用),您的配置工作正常(对我来说docker-compose start backend)。修改backend以重试连接对我来说可靠,即
for {
_, err := cluster.CreateSession()
if err == nil {
break
}
log.Printf("CreateSession: %v", err)
time.Sleep(time.Second)
}
log.Printf("Connected OK")
日志:
backend_1 | 2020/11/04 17:53:23 CreateSession: gocql: unable to create session: unable to discover protocol version: dial tcp 172.26.0.2:9042: connect: connection refused
backend_1 | 2020/11/04 17:53:24 CreateSession: gocql: unable to create session: unable to discover protocol version: dial tcp 172.26.0.2:9042: connect: connection refused
.......
backend_1 | 2020/11/04 17:53:36 CreateSession: gocql: unable to create session: unable to discover protocol version: dial tcp 172.26.0.2:9042: connect: connection refused
backend_1 | 2020/11/04 17:53:37 Connected OK
- 1 回答
- 0 关注
- 153 浏览
添加回答
举报