ingofreyer
ingofreyer

Reputation: 1164

How to fix uWSGI internal routing?

I am closely following the uWSGI tutorial on offloading WebSockets and SSE. However, I have the issue that my Django worker cannot start up since uWSGI is not able to register the route. It is able to register it when I replace the socket of the SSE service with just a log call. I did make sure that the socket exists (I am using an emperor to start up both uWSGI configurations).

I found this other StackOverflow question that suggested to enable PCRE support (which I already did). I do not get the warning about PCRE support anymore in my log file.

I am trying different possibilities for two days now and I definitely need the help of someone with a fresh mind.

This is my log when starting up the django worker (the sse worker is already started up):

/usr/sbin/uwsgi --ini /usr/uwsgi/vassals.d/01_django.ini --die-on-term --need-app --plugin router_redirect
[uWSGI] getting INI configuration from /usr/uwsgi/emperor.ini
[uWSGI] getting INI configuration from /usr/uwsgi/vassals.d/01_django.ini
unable to register route "equal:${CONTENT_TYPE};text/event-stream uwsgi:/tmp/sseapp.sock,0,0"
command terminated with exit code 1

this is my 01_django.ini file:

[uwsgi]
socket = /tmp/django.sock
chown-socket = nginx:nginx
chmod-socket = 664

; wait until the sse app is loaded
wait-for-socket = /tmp/sseapp.sock

; configuring the sse app
; http-socket = :9090
offload-threads = 2
wsgi-file = /srv/okmapgo/okmapgo/wsgi.py
plugins = python

; collect X-Offload-to-SSE header and store it in var X_OFFLOAD
collect-header = X-Offload-to-SSE X_OFFLOAD
collect-header = Content-Type CONTENT_TYPE
; if X_OFFLOAD is defined, do not send the headers generated by Django
;; response-route-if-not = empty:${X_OFFLOAD} disableheaders:
; if X_OFFLOAD is defined, offload the request to the app running on /tmp/sseapp
; start the sseapp beforehand using
; uwsgi --wsgi-file /srv/okmapgo/dilcher_messaging_kafka/sseapp.py --socket /tmp/sseapp --gevent 1000 --gevent-monkey-patch
;; response-route-if-not = empty:${X_OFFLOAD} uwsgi:/tmp/sseapp,0,0
;response-route-if = equal:${CONTENT_TYPE};text/event-stream log:route triggered
response-route-if = equal:${CONTENT_TYPE};text/event-stream uwsgi:/tmp/sseapp.sock,0,0

The commented out "response-rout-if" entry works, the currently active one does not :-/

The referenced socket does exist (the other uwsgi socket is the socket of the emperor):

ls -lahrt /tmp
total 8
drwxr-xr-x    1 root     root        4.0K Nov 15 10:55 ..
srw-rw-r--    1 nginx    nginx          0 Nov 15 11:21 uwsgi.sock
srw-rw-r--    1 nginx    nginx          0 Nov 15 11:21 sseapp.sock
drwxrwxrwt    1 root     root        4.0K Nov 15 11:21 .

I am using uWSGI version 2.0.17.1. Any hints / ideas on how to make this work?

Upvotes: 2

Views: 2323

Answers (1)

Kamil Niski
Kamil Niski

Reputation: 4765

I think that you need to add router_uwsgi plugin to configuration.

Uwsgi docs

Upvotes: 2

Related Questions