App Engine开发服务器 – 套接字的协议类型错误

huangapple go评论85阅读模式
英文:

App Engine dev server - Protocol wrong type for socket

问题

我正在本地使用开发服务器运行一个用Go编写的App Engine应用程序,并使用每秒1个请求的速度向API发送大约100k-1MB的JSON数据。

服务器不时会打印错误跟踪,但仍然继续处理请求:

socket.error 41
Traceback (most recent call last):
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2127, in respond
    self.write(chunk)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2188, in write
    self.req.write(chunk)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 879, in write
    self.conn.wfile.sendall(chunk)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 970, in sendall
    bytes_sent = self.send(data)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 977, in send
    bytes_sent = self._sock.send(data)
error: [Errno 41] Protocol wrong type for socket

客户端循环执行以下操作:

func call(url string, data []byte) error {
    r, err := http.Post(url, "application/json", bytes.NewReader(data))
    if err != nil {
        return err
    }
    defer r.Body.Close()
    if r.StatusCode != http.StatusCreated {
        return fmt.Errorf("unexpected status code %d", r.StatusCode)
    }
    return nil
}

Golang App Engine SDK现在是1.9.26,之前是1.9.25,但问题仍然存在。

我在网上没有找到任何有助于理解此问题的信息。

有人知道这可能是由什么引起的吗?

英文:

I'm running an App Engine app written in Go locally with the development server and hitting the API with requests 1/s with roughly 100k-1MB JSON data.

From time to time the server prints an error trace but still continues to serve requests:

socket.error 41
Traceback (most recent call last):
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2127, in respond
    self.write(chunk)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2188, in write
    self.req.write(chunk)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 879, in write
    self.conn.wfile.sendall(chunk)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 970, in sendall
    bytes_sent = self.send(data)
  File "/Users/foo/go_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 977, in send
    bytes_sent = self._sock.send(data)
error: [Errno 41] Protocol wrong type for socket

The client is in a loop doing:

func call(url string, data []byte) error {
    r, err := http.Post(url, "application/json", bytes.NewReader(data))
    if err != nil {
        return err
    }
    defer r.Body.Close()
    if r.StatusCode != http.StatusCreated {
        return fmt.Errorf("unexpected status code %d", r.StatusCode)
    }
    return nil
}

Golang App Engine SDK is now 1.9.26 and I had 1.9.25 before with the same issue.

I have unsuccessfully found anything online that would help me understand the issue.

Does anyone have an idea what this might be caused by?

答案1

得分: 1

这似乎是从wsgiserver2.py中使用Python套接字引起的错误,因为网络上有很多关于"error 41"和"Protocol wrong type for socket"的参考,都与Python的sockets模块有关。

考虑到这个问题的间歇性,我认为这很可能是平台上的问题。在这种情况下,你应该在公共问题跟踪器中提交一个问题报告,其中包含足够的代码来重现该问题,或者附带一个可以重现该问题的应用程序。

祝你在提交问题报告时好运!

英文:

This appears to be an error bubbling-up from wsgiserver2.py's use of python sockets, since many other references to "error 41" and "Protocol wrong type for socket" show up on the net as python sockets -module-related.

I think given the intermittent nature of this problem that it's likely an issue on the platform. In such a case, you should file an issue report in the public issue tracker containing enough code to reproduce the issue, or an attached app which can reproduced the issue.

Best of luck in filing that issue report!

huangapple
  • 本文由 发表于 2015年9月27日 02:46:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/32800754.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定