简体   繁体   English

发布到Heroku时Node.js请求超时

[英]Node.js Request timeout when post to Heroku

After sending a POST request from my iOS app, I get the below error. 从我的iOS应用发送POST请求后,出现以下错误。 The error doesn't seem to have any effect and everything continues to run fine, but I would like to know how to remove the error (as I worry there is something not entirely right which might have negative effects later)? 该错误似乎没有任何作用,并且一切都可以正常运行,但是我想知道如何消除该错误(因为我担心有些不完全正确的事以后可能会产生负面影响)? I am wondering it there is some way to close off the POST request and avoid the error. 我想知道是否有某种方法可以关闭POST请求并避免错误。

at=error code=H12 desc="Request timeout" method=POST path="/test" host=my-server.herokuapp.com request_id=fea9cffc-5e67-4301-baaa-d2fd18cfd0ea fwd="95.147.171.193" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0

PS: The current iOS code I use is simply PS:我使用的当前iOS代码很简单

@IBAction func Test(_ sender: Any) {

    let url = NSURL(string: "https://my-server.herokuapp.com/test")!
    let request = NSMutableURLRequest(url: url as URL)
    request.httpMethod = "POST"
    URLSession.shared.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
        // TODO: Handle errors
        }.resume()

}

even though I have also tried other versions (especially with more information in the body, which doesn't change anything). 即使我也尝试过其他版本(尤其是在体内具有更多信息的情况下,它都没有任何改变)。

On Heroku, I simply run 在Heroku上,我只是跑步

app.post("/test", function (req, res) {
    console.log("Test Log")
}

which already creates the described error. 已经造成了所描述的错误。

It seems I always get the same error with the POST request, there does not seem to be a problem with GET requests. 似乎我总是在POST请求中遇到相同的错误,而GET请求似乎没有问题。

Please post your code, I cannot comment this as I have low reputaion. 请发布您的代码,由于信誉不佳,我无法对此发表评论。

Request timeouts are due to the server not responding. 请求超时是由于服务器没有响应。

Check this post , and see if you have set up the server properly. 检查这篇文章 ,看看是否已经正确设置了服务器。

If the error persists, try using a get request instead. 如果错误仍然存​​在,请尝试使用get请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM