0

我能够将图像表单数据从 Postman 发送到我的 Heroku Flask 服务器,但是当我从 Node JS 发送时,我收到此处描述的错误: https ://help.heroku.com/18NDWDW0/debugging-h18-server-request -interrupted-errors-in-nodejs-applications,即“套接字已连接,一些数据已作为应用程序响应的一部分发送,但随后套接字在未完成响应的情况下被破坏。”

    let data = new FormData();
    data.append("image", image, {filename: image.url});
    return axios.post('herokuflaskserver.com/look-at-image', 
        data, {
        headers: { 
            "Content-Type": `multipart/form-data; boundary=${data._boundary}` 
        }
    }).catch((err) => {
        // 503 error logged here
    }).then((response) => {
        return response.data;
    });

根据该路由器,我将该请求发送到具有 200 的 Flask 服务器。

@app.route('/look-at-image', methods = ['POST'])
def look_at_image():
    images = request.files.getlist("image")

但我得到了错误sock=backend at=error code=H18 desc="Server Request Interrupted"。我研究了错误并尝试添加 10 秒的睡眠,错误消失但request.files为空。我认为 Flask 服务器在获取所有图像数据之前正在发送响应。有谁知道为什么从这个后端发送它不起作用?非常感谢。

4

1 回答 1

1

通过切换到使用女服务员而不是 gunicorn 解决

web: waitress-serve --port=$PORT app:app
于 2020-06-08T21:53:11.997 回答