wandenberg / nginx-push-stream-module

A pure stream http push technology for your Nginx setup. Comet made easy and really scalable.
Other
2.21k stars 295 forks source link

(Question) Detect websocket close event #300

Closed futuarmo closed 2 years ago

futuarmo commented 2 years ago

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.

sunnychun commented 2 years ago

您的信已收到,我将尽快给您答复

wandenberg commented 2 years ago

@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.

futuarmo commented 2 years ago

@wandenberg Thank you for information