[Python] django, gunicorn, grpc: "Failed to pick subchannel" if run django grpc client with...

Discussão em 'Python' iniciado por Stack, Julho 1, 2025.

  1. Stack

    Stack Membro Participativo

    I am a beginner in the Django framework. I wrote an application consist of 2 microservices. One as a Django Rest Server and the other as a Django GRPC Server. the rest request translated to GRPC requests in the first server and sent to the second for the process.

    ------>|-----------|------->|-----------|
    |rest server| |grpc server|
    | | | |
    <------|-----------|<-------|-----------|


    when I ran the first server with python manage.py runserver ip:port the application works properly. but when I ran the first server with gunicorn myapp.wsgi --workers=1 --bind=ip:port, a grpc request from the rest server randomly counter an error:

    {"created":"@1593330482.005402565","description":"Failed to pick
    subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3981,"refer
    enced_errors":[{"created":"@1593330482.005396918","description":"failed to connect to all
    addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_l
    ine":394,"grpc_status":14}]}


    the interesting thing is the grpc request was received by grpc server and it sent back the response.

    wsgi.py:

    import os

    from django.core.wsgi import get_wsgi_application

    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings')

    application = get_wsgi_application()

    Continue reading...

Compartilhe esta Página