gin icon indicating copy to clipboard operation
gin copied to clipboard

write: broken pipe

Open cyanBone opened this issue 4 years ago • 6 comments

  • With issues:
    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.

Description

Access too fast 2021/02/20 22:22:29 write tcp 127.0.0.1:8080->127.0.0.1:54110: write: broken pipe

How to reproduce

package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	g := gin.Default()
	g.GET("/", func(c *gin.Context) {
		c.Html(200, "123.html", nil)
	})
	g.Run(":9000")
}

Expectations

chrome Access too fast http://127.0.0.1:9000

Actual result

none

Environment

  • go version:1.16
  • gin version (or commit ref):v1.6.3
  • operating system: mac os 11.2.1 (20D74) os x64

cyanBone avatar Feb 20 '21 14:02 cyanBone

Any update here?

ankur-lt avatar Jul 23 '21 09:07 ankur-lt

I am using a nice-recovery yet this broken pipe still manages to trigger a panic that crashes the service. How are people getting around it?

panic: write tcp 127.0.0.1:5569->127.0.0.1:34348: write: broken pipe
github.com/gin-gonic/gin.(*Context).Render(0xc001018100, 0xc8, 0x16cb460, 0xc000ed4390)
        /home/niko/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:914 +0x17c
github.com/gin-gonic/gin.(*Context).Data(...)
        /home/niko/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:1003
....
panic: write tcp 127.0.0.1:5569->127.0.0.1:34426: write: broken pipe

nikooo777 avatar Aug 05 '21 14:08 nikooo777

i have the same problem, how to fix it?

http: panic serving ***********: write tcp ********->*********: write: broken pipe
golang/src/net/http/server.go:1767
golang/src/runtime/panic.go:679 +0x1b2
github.com/gin-gonic/gin/render.JSON.Render(...)
	/***/jenkins/go/pkg/mod/github.com/gin-gonic/[email protected]/render/json.go:56

Environment

  • gin 1.7.4
  • golang 1.13
  • os linux

le011 avatar Mar 28 '22 07:03 le011

I ended up putting this in my handler:

defer func() {
	if r := recover(); r != nil {
		log.Errorf("Recovered from panic: %v", r)
	}
}()

it doesn't really fix it but at least it's a bit cleaner...

nikooo777 avatar Mar 31 '22 21:03 nikooo777

anyone sloved this problem ? i mean , i got the same problem,and i do not known how to fix it .

gin: v1.7.7 go: 1.15

XieWeiXie avatar Mar 31 '23 02:03 XieWeiXie

Hi @XieWeiXie! The issue has been fixed by #2150 PR. Please, upgrade gin to v1.9 and also update the version of golang. @thinkerou @appleboy Could you close this issue?

EugeneTorap avatar Mar 31 '23 06:03 EugeneTorap