node.jsexpressstreamrequestnpm-request

NPM-Request handle on data stop flowing/streaming


I'm piping a CCTV stream using request, and serve it using Express. Sometimes there is problem with network connection in the middle of streaming, that cause in the client picture freeze on the last chunked data.

I need to catch this event so I can manipulate on the client by serve some-error image file. I tried exit, close, finish, stop events but none success. So far I didn't found similar problem on request's Issues or on other SO questions.


Solution

  • Sorry for being late,

    I figure out that passing timeout option can catch network disconnection and trigger error event. It printed as Error: ESOCKETTIMEDOUT.

    This is quite enough for my needs.