dtyyrt4545 2016-04-21 02:58
浏览 259

HTTP连接停留在close_wait状态

I'm using gin to build a simple api server. right now, after the server started a few minutes later, all of incoming requests were stuck. After checking connections state , I got a message like below :enter image description here

I already have tried to set c.Request.Close=true or c.Header("Connection","close") or both of them, but it was not working. I was wondering if anyone can help me fix this issue.

UPDATE-1 the way to start server

            runtime.GOMAXPROCS(runtime.NumCPU())
            //start serving
            r := gin.New()
            r.Use(gin.LoggerWithWriter(logFile))
            r.Use(gin.RecoveryWithWriter(logFile))
            r.Use(handler.SetResponseHeader())
            controller.Router.RegisterRouter(r, cfg)

            //r.Run(cfg.SvcHost)
            s := &http.Server{
                Addr:    cfg.SvcHost,
                Handler: r,
            }
            s.ListenAndServe()

UPDATE-2

after temporarily disabling the global gorm.DB instance and creating a new db connection for each request, this issue didn't occur any more.

  • 写回答

1条回答 默认 最新

  • doudou1309 2016-04-21 03:16
    关注

    TCP is waiting for you to close those connections. Probably you have read end of stream from them and have ignored it.

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式