为了账号安全,请及时绑定邮箱和手机立即绑定

uWSGI 和 Zuul:所有其他请求都失败

uWSGI 和 Zuul:所有其他请求都失败

小唯快跑啊 2023-06-28 16:27:05
我有一个设置(微服务),其中 Zuul 网关(localhost)位于使用 uWSGI 服务的 Flask REST API 应用程序(localhost:8080)前面。当我尝试通过网关访问 API 时(例如curl http://localhost/api/endpoint),所有其他请求都会失败(HTTP 500)。API 端没有日志,以下是非常密集的网关异常日志的摘录:com.netflix.zuul.exception.ZuulException: Forwarding error...Caused by: com.netflix.client.ClientException: null...Caused by: java.lang.RuntimeException: org.apache.http.NoHttpResponseException: localhost:8080 failed to respond不过,当我直接访问 API时(例如),它工作得很好(每个请求都按预期处理)。curl http://localhost:8080/api/endpoint另一个有趣的事情是,如果使用 Flask 的开发服务器而不是 uWSGI,当我尝试通过网关访问 API 时,它会起作用。这是我的 uWSGI 设置:[uwsgi]wsgi-file = api.pycallable = appuid = apigid = apimaster = trueprocesses = 2threads = 2http-timeout = 300socket-timeout = 300harakiri = 300http = 0.0.0.0:8080socket = /tmp/uwsgi.socketchmod-sock = 664vacuum = truedie-on-term = truewsgi-disable-file-wrapper = truelog-date = %%Y-%%m-%%d %%H:%%M:%%Slogformat-strftime = truelogformat = %(ftime) | uWSGI    | %(addr) (%(proto) %(status)) | %(method) %(uri) | %(pid):%(wid) | Returned %(size) bytes in %(msecs) ms to %(uagent)版本是spring-cloud-netflix-zuul-2.1.1.RELEASE.jar和uwsgi==2.0.17.1。Wireshark 检查显示TCP 8080 -> 80 [RST] Seq=123 Win=0 Len=0知道这里可能有什么问题吗?
查看完整描述

1 回答

?
忽然笑

TA贡献1806条经验 获得超5个赞

通过将 NGINX 置于 uWSGI 之上来解决。

NGINX 监听端口 8080 并通过 unix 套接字与 uWSGI 对话,因此从 Zuul 的角度来看,没有任何变化。


查看完整回答
反对 回复 2023-06-28
  • 1 回答
  • 0 关注
  • 105 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信