title: How to fix : Received RST_STREAM with error code 2 when using nginx reverse proxy
body: <p>I'm currently using the dialogflow api on a raspberry. 
  Everything works fine when calling StreamingDetectIntent method using grpc. 
  I have to use multiples apis on my product and so, I'm trying to put a reverse proxy in front of them. Like that, I can call only one address
  I'm using nginx to reverse proxy my GRPC request to google api. 
  I have no problem when calling simple method, but when calling a streaming method like StreamingDetectIntent, I got an error during the request. </p>
  
  <p>Dialogflow do not have problem to get the audio flux coming from my client, but I got problem to get the last part of the request, the downstream flux. </p>
  
  <p>Here is the error that my client give me  : </p>
  
  <pre><code>grpc._channel._Rendezvous: &lt;_Rendezvous of RPC that terminated with:
          status = StatusCode.INTERNAL
          details = "Received RST_STREAM with error code 2"
          debug_error_string = "{"created":"@1567173815.816362297","description":"Error received from peer ipv4:163.172.143.250:443","file":"src/core/lib/surface/call.cc","file_line":1041,"grpc_message":"Received RST_STREAM with error code 2","grpc_status":13}"
  &gt;
  </code></pre>
  
  <p>and here the error I can see in Nginx log  : </p>
  
  <pre><code>upstream sent frame for closed stream 1 while reading upstream, client: ..., server: exemple.com, request: "POST /google.cloud.dialogflow.v2beta1.Sessions/StreamingDetectIntent HTTP/2.0", upstream: "grpcs://...:443", host: "example.com:443"
  </code></pre>
  
  <p>I've tried to increase grpc_buffer_size parameter to big value, but didn't worked.. </p>
  
  <p>Here is my current Nginx config :</p>
  
  <pre><code>user  nginx;
  worker_processes  1;
  
  error_log  /var/log/nginx/error.log debug;
  pid        /var/run/nginx.pid;
  
  events {
      worker_connections  1024;
  }
  
  http {
  
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
  
      sendfile        on;
  
      keepalive_timeout  65;
  
      client_max_body_size 4000M;
      grpc_read_timeout 1d;
      grpc_send_timeout 1d;
      # this seems to fix it; but see comment in README.md
      grpc_buffer_size 100M;
  
      include /etc/nginx/conf.d/*.conf;
  
      server {
  
          # SSL configuration
          listen 443 ssl http2;
  
          access_log /var/log/nginx/access_grpc.log main;
  
          location / {
              grpc_pass grpcs://dialogflow.googleapis.com:443;
          }
  
          ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
          ssl_certificate_key/etc/letsencrypt/live/exemple.com/privkey.pem;
      }
  
      server {
  
          if ($host = example.com) {
              return 301 https://$host$request_uri;
          }
  
          listen 80 ;
          listen [::]:80 ;
  
          return 404; # managed by Certbot
  
      }
  
  }
  
  </code></pre>