• [Go] 解决packets.go:36: read tcp 127.0.0.1:51139->127.0.0.1:3306: wsarecv: An established connection was aborted by the software in your host ma chine.


    这是因为数据库的超时时间比较短,连接被mysql服务关闭了

    程序还在使用旧连接查询数据库

    比如gorm

    我们程序里设置下时间旧可以了,时间比超时时间短一些

    DB.DB().SetConnMaxLifetime(59 * time.Second)

        DB, err = gorm.Open("mysql", dsn)
        if err != nil {
            log.Println(err)
    
            panic("数据库连接失败!")
            return err
        }
        DB.SingularTable(true)
        DB.LogMode(true)
    
        DB.DB().SetMaxIdleConns(10)
        DB.DB().SetMaxOpenConns(100)
        DB.DB().SetConnMaxLifetime(59 * time.Second)

    开源作品

    GO-FLY,一套可私有化部署的免费开源客服系统,安装过程不超过五分钟(超过你打我 !),基于Golang开发,二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能
    github地址:go-fly
    官网地址:https://gofly.sopans.com
  • 相关阅读:
    Gym 101194L / UVALive 7908
    POJ 2259
    POJ 2559
    Gym 101194E / UVALive 7901
    Gym 101194D / UVALive 7900
    一种整数集上二分的正确写法
    日常训练记录
    Gym 101194C / UVALive 7899
    Gym 101194A / UVALive 7897
    HDU 5542
  • 原文地址:https://www.cnblogs.com/taoshihan/p/15389102.html
Copyright © 2020-2023  润新知