GCE 运行 Bottle 停止监听 http 请求

GCE running Bottle stops listening to http requests

我在 GCE 服务器(一个简单的乒乓服务器)上有一个非常简单的 bottle 应用程序 运行:

import bottle

@bottle.route('/ping')
def ping():
    return 'pong'

SERVER_PORT = 5000

if __name__ == "__main__":
    bottle.run(host = '0.0.0.0', port = SERVER_PORT)

我可以按预期发送 ping 和获取 pong,但是如果我让它静置一段时间(时间量发生变化)并再次发送 ping,我看不到服务器收到请求的迹象,并且请求超时无应答。

我的服务器是 运行 Ubuntu 和 Python3.6,我正在使用 screen 在 ssh 连接断开时保持服务器活动。

这是我到目前为止尝试过的方法:

我做错了什么?

编辑: 请求似乎确实挂在服务器上:当我发送 ping 并等待响应时,如果我在运行时终止服务器应用程序等待我会立即得到一个 "page not found" 页面。但出于某种原因,瓶子无法识别该请求。

原来是bottle默认的HTTP开发服务器导致的问题。 将服务器更改为 cherrypy 解决了问题(并使我的应用程序响应速度更快)。

import bottle

@bottle.route('/ping')
def ping():
    return 'pong'

SERVER_PORT = 5000

if __name__ == "__main__":
    bottle.run(host = '0.0.0.0', port = SERVER_PORT, server = 'cherrypy')