drvpvmz16241016 2018-02-01 17:17
浏览 48

在App Engine灵活环境中发送HTTP Get请求时出现Nginx错误

I am sending HTTP GET request in my App

When I send the request using http.Get(URL) just like the following code I get 200 as HTTP status code:

resp, err := http.Get("https://www.google.co.in/")
if err != nil {
    http.Error(w, err.Error(), http.StatusInternalServerError)
    return
}
fmt.Fprintf(w, "HTTP GET returned status %v", resp.Status)

But if I use http.NewRequest() and http.Client just like the following code I get 502 Bad Gateway nginx error

req, err := http.NewRequest("GET", "https://www.google.co.in/", nil)
resp, err := client.Do(req)
if err != nil {
    http.Error(w, err.Error(), http.StatusInternalServerError)
    return
}
fmt.Fprintf(w, "HTTP GET returned status %v", resp.Status)

I checked Stackdriver log for nginx.error I see the following error

[error] 32#32: *6597 upstream prematurely closed connection while 
reading response header from upstream, client: $client_ip, server: , 
request: "GET /check HTTP/1.1", upstream: 
"http://172.17.0.1:8080/check", host: "XXX.appspot.com"

I am new to App Engine and also I have limited knowledge of Nginx.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?