nginx 504后其他请求均失败
windows当一个请求504后其他请求均502,错误日志:
connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: 127.0.0.1, server: _, request: "GET /websocket/ HTTP/1.1", upstream: "https://127.0.0.1:8086/websocket/", host: "127.0.0.1:8081"
upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while SSL handshaking to upstream, client: 127.0.0.1, server: _, request: "POST /routerAndPhoneInfo/ HTTP/1.1", upstream: "https://127.0.0.1:8083/routerAndPhoneInfo/", host: "127.0.0.1:8081", referrer: "https://127.0.0.1:8081/"
no live upstreams while connecting to upstream, client: 127.0.0.1, server: _, request: "POST /routerAndPhoneInfo/ HTTP/1.1", upstream: "https://backs/routerAndPhoneInfo/", host: "127.0.0.1:8081", referrer: "https://127.0.0.1:8081/"
def init_server_socket():
# 请求服务端登录
global socket_server
try:
socket_obj = SocketHandle(server_addr=configPara.SERVER_ADDR, server_port=configPara.ELF_PORT)
client_conn_socket = socket_obj.socket_connect()
socket_server = client_conn_socket
sock_login()
except Exception as e:
msg = err_record_log(self=None, e=e)
log_err.error(msg)
def socket_send(data=None, sock=None):
global socket_server
global g_token
data['timestamp'] = int(time.time())
try:
if not socket_server:
init_server_socket()
data['token'] = g_token
print(f'send_data:{data}')
data = json.dumps(data).encode()
data_len = struct.pack('i', len(data))
socket_server.sendall(data_len)
socket_server.sendall(data)
except Exception as err:
msg = err_record_log(self=None, e=err)
log_err.error(msg)
socket_server.close()
socket_server = None
g_token = None
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是用代码模拟的、还是后面服务真挂了?
真挂了这是正常的,因为 504 就是后面服务没在规定时间内返回响应,I/O 阻塞住了,大概率是死掉了;而再进来的请求很可能后面服务已经不能正常处理了(连接收报文都无法做到),从 TCP 包上看就是奇怪的结果,nginx 不认识,所以就 502 了。