(Question) Detect websocket close event
futuarmo opened this issue · 3 comments
Hello! I have a question, please, help to find an answer
Here is the case:
I have nginx with pushstream module. When I send a lot of messages with high rate, my websocket connection closes and I lose some messages.
I found the reason: net.ipv4.tcp_wmem cache size.
But I want to log moment when websocket closes.
Please, help me to find that place in pushstream module source code.
In code it looks like this call chain:
ngx_http_push_stream_process_worker_message
ngx_http_push_stream_process_worker_message_data
ngx_http_push_stream_respond_to_subscribers
and there in lines:
if (msg != NULL) {
// now let's respond to some requests!
for (q = ngx_queue_head(subscriptions); q != ngx_queue_sentinel(subscriptions);) {
And at that moment subscriptions are empty. As I understand somewhere websocket was closed and subscribers were removed.
@futuarmo assuming that the connection is ended by the core of Nginx due to an error related to the configuration you mentioned, the only place to log this would be the handler defined to when a request is closed.
The challenge will be to distinguish between the normal close and a close due to an error.
It would be required a deeper investigation to see if on the request instance has some information noted on it.
@wandenberg Thank you for information