I have a setup (microservices) in which Zuul gateway (localhost) is in front of a flask REST API app (localhost:8080) served with uWSGI.
When I try to reach the API via gateway (e.g. curl http://localhost/api/endpoint
), every other request fails (HTTP 500). There are no logs on the API side and here's an extract from the very dense gateway's exception log:
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
Though, it works perfectly fine (every requests is handled as expected) when I reach the API directly (e.g. curl http://localhost:8080/api/endpoint
).
Another interesting thing is that it works when I try to reach the API via gateway if flask's development server is used instead of uWSGI.
Here's my uWSGI settings:
[uwsgi]
wsgi-file = api.py
callable = app
uid = api
gid = api
master = true
processes = 2
threads = 2
http-timeout = 300
socket-timeout = 300
harakiri = 300
http = 0.0.0.0:8080
socket = /tmp/uwsgi.socket
chmod-sock = 664
vacuum = true
die-on-term = true
wsgi-disable-file-wrapper = true
log-date = %%Y-%%m-%%d %%H:%%M:%%S
logformat-strftime = true
logformat = %(ftime) | uWSGI | %(addr) (%(proto) %(status)) | %(method) %(uri) | %(pid):%(wid) | Returned %(size) bytes in %(msecs) ms to %(uagent)
Versions are spring-cloud-netflix-zuul-2.1.1.RELEASE.jar
and uwsgi==2.0.17.1
.
Wireshark inspection shows TCP 8080 -> 80 [RST] Seq=123 Win=0 Len=0
Any idea what may be the issue here?
Solved by putting NGINX on top of uWSGI.
NGINX listens on port 8080 and talks to uWSGI over an unix socket so nothing changed from Zuul's point of view.