2

Our stack is Client(Browser) <-> Nginx Reverse Proxy <-> Webserver(Flask+Gunicorn) <-> Golang gRPC server

The problem is when the client makes a call to the /realtimedata endpoint, Flask then opens the gRPC connection and starts receiving data via a server->client unidirectional stream. It then passes it back to the client. When I run this without Nginx, I get all responses. When running with Nginx, some responses get truncated. For example, if we expect:

{
    "source": "serviceA",
    "timestamp": 123456789,
    "data": {
        "1": 24.55667,
        "2": -456.5656,
        ...
        "200": 5.678
    }
}

We get

{
    "source": "serviceA",
    "time

Then

        stamp": 123456789,
    "data": {
        "1": 24.55667,
        "2": -456.5656,
        ...
        "200": 5.678
    }
}

This would be printed in console.log. I have proxy_buffering off; in the nginx configuration otherwise no data makes it to the browser. Not sure how to resolve this issue.

Here is a minimum, reproducible example.

UPDATE: I've ran the minimum reproducible example with Apache2 instead of Nginx and experiencing the same random truncations.

  • What do you mean by "We get [...] and then [...]"?! That you receive all the data anyway? I don't see why that would be an issue. – Alexis Wilke Feb 27 '22 at 22:40
  • 1
    I print the response in the console on the browser. So I'll receive for example one half of the response, then the other. But it is an issue because `response.JSON()` yields an error when it's truncated like that. – Paul Côté Feb 28 '22 at 14:27

1 Answers1

0

I had the similar behavior from Apache(!) breaking up a html file respone from django. It always broke at the same position without any reason. I finally found that I accidentally did install a mod_wsgi package into Apache from a Python version that did not match the version Apache was calling my app in. Maybe it helps you.

Razenstein
  • 126
  • 3