go服务通常会收到错误消息“关闭错误的空闲连接:由对等方重置连接”。
Error log
[mysql] 2021/01/16 20:08:27 packets.go:122: closing bad idle connection: connection reset by peer
[mysql] 2021/01/16 20:13:27 packets.go:122: closing bad idle connection: connection reset by peer配置
知道怎么解决这个问题吗?
发布于 2021-12-14 22:06:21
如果数据库连接长期处于打开状态,则需要定期检查该连接。
func checkPing() {
for {
time.Sleep(time.Second * 15)
err := DB.DB().Ping()
if err != nil {
log.Println(err)
}
}
}https://stackoverflow.com/questions/70353426
复制相似问题