Nginx Truncating Server->Client Stream Response

104 views
Skip to first unread message

Paul Cote

unread,
Nov 22, 2021, 1:13:10 PM11/22/21
to grpc.io
Hello,

I've been struggling to resolve this particular issue. I have a Golang gRPC server which streams data to a Flask/Gunicorn webserver and then passes it on to the client. I have Nginx running as a reverse proxy in front of my webserver

  Client(Browser) <-> Nginx Reverse Proxy <-> Webserver(Flask/Gunicorn) <-> go-grpc server

Essentially, the user on their browser will click a button which is just an AJAX call (/stream) to the backend webserver. Then the webserver, which is the gRPC client, will make the actual gRPC call and yield all responses back to the client. Some of them get truncated. For example if we expect:

{
    "source": "serviceA",
    "timestamp": 123490435,
    "data": {
        "1": 3446.706,
        "2": -45.343464,
         ...
        "200": 5.3545
    }
}

We may only get:
{
    "source": "serviceA",
    "ti

And then:
    mestamp": 123490435,
    "data": {
        "1": 3446.706,
        "2": -45.343464,
         ...
        "200": 5.3545
    }
}
In the next frame. Where the truncation happens is random and when it happens is also random. If my setup doesn't make any sense, please let me know on better ways to integrate a gRPC client.

I've isolated the problem to nginx. If I run this without nginx, I get no truncations. I've tried `proxy_buffering off;` and a myriad other nginx paramters but nothing seems to work. 

Thank you,

Paul C.

Paul Cote

unread,
Nov 23, 2021, 4:12:51 PM11/23/21
to grpc.io

I've just tried this with Apache2 as well and I'm getting the same random truncations. Maybe this is a gRPC issue?

Paul Côté

unread,
Nov 25, 2021, 9:51:45 PM11/25/21
to grpc.io
I figured it out. I rewrote the webserver backend and frontend to use websockets instead of what I was doing!
Reply all
Reply to author
Forward
0 new messages