Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write: broken pipe #2644

Open
cyanBone opened this issue Feb 20, 2021 · 6 comments
Open

write: broken pipe #2644

cyanBone opened this issue Feb 20, 2021 · 6 comments

Comments

@cyanBone
Copy link

cyanBone commented Feb 20, 2021

  • 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
@ankur-lt
Copy link

Any update here?

@nikooo777
Copy link

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/gin@v1.7.1/context.go:914 +0x17c
github.com/gin-gonic/gin.(*Context).Data(...)
        /home/niko/go/pkg/mod/github.com/gin-gonic/gin@v1.7.1/context.go:1003
....
panic: write tcp 127.0.0.1:5569->127.0.0.1:34426: write: broken pipe

@le011
Copy link

le011 commented Mar 28, 2022

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/gin@v1.7.4/render/json.go:56

Environment

  • gin 1.7.4
  • golang 1.13
  • os linux

@nikooo777
Copy link

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...

@XieWeiXie
Copy link

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

@EugeneTorap
Copy link

EugeneTorap commented Mar 31, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants