Nginx successfully detect when a client disconnects before the response is sent, and it is logged in the access logs as code 499 But my FastCGI (in C) app does not give out any error during responding.
Is there a way to detect client timeout in FastCGI(in C) behind nginx?
Ok. I found the answer.
There was a link which asked to use FCGX_GetError() to detect the error, after writing to the stream.
The problem is that the IO is buffered, hence there is no error reported.
So I used FCGX_FFlush(request.out) It worked like a charm, giving -1 when the client times out.
Note: nginx detects this client disconnect and enters a code 499 in the access log.