首页
首页
文章目录
  1. 简介
  2. 解决方法

nginx 10054 An existing connection was forcibly closed by the remote host 报错修复

简介

今天项目上,与一个银行对接,银行只有内存, 而我们的对账服务需要拉取银行支付账单,也需要拉取支付宝微信账单,所以使用nginx将内网的银行对账地址转发到有互联网的前置机上面。

程序在第一次调用的时候正常,第二次调用的时候就报错提示: *1 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 127.0.0.1, server: localhost错误。

解决方法

这是由于nginx反向代理长连接导致的.
nginx.conf 添加配置文件

1
2
3
4
5
6
http {
...
keepalive_requests 8192;
 keepalive_timeout 180;
...
}

nginx中http配置 nginx中http配置

1
2
3
4
5
6
7
8
9
server {
listen 8080;
...
location / {
proxy_http_version 1.1;
proxy_set_header Connection keep-alive;
proxy_pass http://httpurl;
}
}

nginx中server配置 nginx中server配置

备注:HTTP 1.1规范中,并没有像HTTP/2中的请求标示符,一条keepalive的TCP连接,一次只能发送一个http请求,直到该请求返回,才能发第二个。

以上,End!

支持一下
扫一扫,我会更有动力更新
  • 微信扫一扫
  • 支付宝扫一扫