How to fix uWSGI internal routing?












1















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?










share|improve this question























  • It's my blind guess but have you tried adding router_uwsgi plugin? Docs say that it is needed. uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#uwsgi

    – Kamil Niski
    Nov 18 '18 at 7:24











  • Thanks, that most likely would have been the issue :-) However, I noticed an even easier mistake: I recompiled uwsgi with pip without removing the Alpine Linux package first - and then called the alpine version instead of the pip version. Calling the Alpine version loaded the correct plugins (including the one mentioned by you) and routing worked. Since your comment still sounds like it would solve the issue, I will accept it as an answer, if you quickly write one.

    – ingofreyer
    Nov 19 '18 at 6:56
















1















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?










share|improve this question























  • It's my blind guess but have you tried adding router_uwsgi plugin? Docs say that it is needed. uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#uwsgi

    – Kamil Niski
    Nov 18 '18 at 7:24











  • Thanks, that most likely would have been the issue :-) However, I noticed an even easier mistake: I recompiled uwsgi with pip without removing the Alpine Linux package first - and then called the alpine version instead of the pip version. Calling the Alpine version loaded the correct plugins (including the one mentioned by you) and routing worked. Since your comment still sounds like it would solve the issue, I will accept it as an answer, if you quickly write one.

    – ingofreyer
    Nov 19 '18 at 6:56














1












1








1








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?










share|improve this question














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?







django server installation uwsgi






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 11:26









ingofreyeringofreyer

514617




514617













  • It's my blind guess but have you tried adding router_uwsgi plugin? Docs say that it is needed. uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#uwsgi

    – Kamil Niski
    Nov 18 '18 at 7:24











  • Thanks, that most likely would have been the issue :-) However, I noticed an even easier mistake: I recompiled uwsgi with pip without removing the Alpine Linux package first - and then called the alpine version instead of the pip version. Calling the Alpine version loaded the correct plugins (including the one mentioned by you) and routing worked. Since your comment still sounds like it would solve the issue, I will accept it as an answer, if you quickly write one.

    – ingofreyer
    Nov 19 '18 at 6:56



















  • It's my blind guess but have you tried adding router_uwsgi plugin? Docs say that it is needed. uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#uwsgi

    – Kamil Niski
    Nov 18 '18 at 7:24











  • Thanks, that most likely would have been the issue :-) However, I noticed an even easier mistake: I recompiled uwsgi with pip without removing the Alpine Linux package first - and then called the alpine version instead of the pip version. Calling the Alpine version loaded the correct plugins (including the one mentioned by you) and routing worked. Since your comment still sounds like it would solve the issue, I will accept it as an answer, if you quickly write one.

    – ingofreyer
    Nov 19 '18 at 6:56

















It's my blind guess but have you tried adding router_uwsgi plugin? Docs say that it is needed. uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#uwsgi

– Kamil Niski
Nov 18 '18 at 7:24





It's my blind guess but have you tried adding router_uwsgi plugin? Docs say that it is needed. uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html#uwsgi

– Kamil Niski
Nov 18 '18 at 7:24













Thanks, that most likely would have been the issue :-) However, I noticed an even easier mistake: I recompiled uwsgi with pip without removing the Alpine Linux package first - and then called the alpine version instead of the pip version. Calling the Alpine version loaded the correct plugins (including the one mentioned by you) and routing worked. Since your comment still sounds like it would solve the issue, I will accept it as an answer, if you quickly write one.

– ingofreyer
Nov 19 '18 at 6:56





Thanks, that most likely would have been the issue :-) However, I noticed an even easier mistake: I recompiled uwsgi with pip without removing the Alpine Linux package first - and then called the alpine version instead of the pip version. Calling the Alpine version loaded the correct plugins (including the one mentioned by you) and routing worked. Since your comment still sounds like it would solve the issue, I will accept it as an answer, if you quickly write one.

– ingofreyer
Nov 19 '18 at 6:56












1 Answer
1






active

oldest

votes


















1














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



Uwsgi docs






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318430%2fhow-to-fix-uwsgi-internal-routing%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














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



    Uwsgi docs






    share|improve this answer




























      1














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



      Uwsgi docs






      share|improve this answer


























        1












        1








        1







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



        Uwsgi docs






        share|improve this answer













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



        Uwsgi docs







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 7:11









        Kamil NiskiKamil Niski

        2,6341314




        2,6341314
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318430%2fhow-to-fix-uwsgi-internal-routing%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues