title: NGINX RTMP Live Streaming Input/output error using on_publish to access external microservice
body: <p>Nginx.conf</p>
  <pre><code>rtmp {
      server {
          listen 1935;
          chunk_size 4000;
          application stream {
              live on;
              #exec ffmpeg -i rtmp://localhost:1935/stream/$name -codec copy -f flv rtmp://$name-live-encoder/play;
              on_publish http://&lt;hostName&gt;:&lt;port&gt;/auth/validate;
              exec ffmpeg -re -i rtmp://localhost:1935/stream/$name -codec copy -bsf:v h264_mp4toannexb -f mpegts udp://live-${name}-udp-encoder-service.rtmp-live-test:3555;
          }
      }
  }
  </code></pre>
  <p>Incoming RTMP stream : rtmp://host:port/stream/ksptv?secret=234rfghi4e</p>
  <p>Microservice : http://HOSTNAME/auth/validate?name=ksptv&amp;secret=234rfghi4e ==&gt; will return 201 if the secret Key matches with channel or 403 if it doesnt match ..</p>
  <p>when the RTMP is getting streamed , the stream is exited with I/O error
  <strong>input rtmp stream logs</strong></p>
  <blockquote>
  <p>rtmp://rtmpHOST/stream/qptv-ind1?secret=hYn4cyWW56WdAhLussHkUw==:
  Input/output error [AVIOContext @ 0x2291f00] Statistics: 199663 bytes
  read, 0 seeks</p>
  </blockquote>
  <p>The on_publish is not processing or hitting the microservice when using as below</p>
  <pre><code>        on_publish http://&lt;hostName&gt;:&lt;port&gt;/auth/validate;
  </code></pre>
  <p>But when I implement on_publish with localhost/auth and have server block defined in nginx.conf with <strong>location /auth {return 201}</strong> , rtmp streaming is successful</p>
  <p>Can you please help me to understand why on_publish is not working with external url/api.</p>