doushang1964 2016-10-11 16:51
浏览 469

Golang:ExecuteTemplate导致错误:`write tcp 127.0.0.1:8080->127.0.0.1:35212:write:有多个请求的管道损坏

I have something like this:

t, err1 := template.ParseFiles("exampleFile.tmpl")
if err1 != nil {
    panic(err1)
}
err2 := t.ExecuteTemplate(w, "example", someStruct)
if err2 != nil {
    panic(err2)
}

With simple requests, there are no problems.

But if I send two requests very close to each other, about 40% of the time from simple page refreshes from Chrome and a few ajax requests, it results in various different errors (err2):

  • write tcp 127.0.0.1:8080->127.0.0.1:35212: write: broken pipe
  • write: connection reset by peer
  • use of closed network connection
  • http: panic serving 127.0.0.1:35814: runtime error: slice bounds out of range goroutine 340 (...)

Others seem to have had similar issues, but with no clear resolution.

Another post seems to suggest just to expect this, and retry failed requests:

What's the best Golang way to handle this?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 matlab求解平差
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
    • ¥15 安装svn网络有问题怎么办
    • ¥15 vue2登录调用后端接口如何实现
    • ¥85 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?