wandenberg / nginx-push-stream-module

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

Doesn't enable keepalive functionality on push_stream_publisher and cann't receive the heartbeat data #157

Closed solderain closed 10 years ago

solderain commented 10 years ago

Q1: I want to enable keep-alive functionality on push_stream_publisher , but i found that directive( push_stream_keepalive ) is no longer valid and cann't pass tesing , incredible push_stream_subscriber is enabled keepalive default (don't need to set keepalive directive) .

Q2: I found the client cann't receive the heatbeat data although have been set the directive 'push_stream_ping_message_text' and 'push_stream_ping_message_text'

using release version: 0.4.0

I am not sure if that cause by mistake configuration .Below is my configureation:

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 1024; use epoll; }

http {

include mime.types;

  #default_type  application/octet-stream;
 #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 #                  '$status $body_bytes_sent "$http_referer" '
 #                  '"$http_user_agent" "$http_x_forwarded_for"';
access_log  logs/access.log  ;

#sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  0;

push_stream_shared_memory_size                100m;
push_stream_max_channel_id_length             200;
# max messages to store in memory
push_stream_max_messages_stored_per_channel   20;
# message ttl
push_stream_message_ttl                       5m;
# ping frequency
# connection ttl to enable recycle
push_stream_subscriber_connection_ttl         15m;
# connection ttl for long polling
push_stream_longpolling_connection_ttl        30s;
push_stream_timeout_with_body                 off;
#push_stream_ping_message_text             'hiboy'; 

#gzip  on;

server {
             listen       80;
            server_name  localhost;
            #charset koi8-r;
            #access_log  logs/host.access.log  main;

    location / {
           root   html;
            index  index.html index.htm;
    }

    location /channels-stats {
        # activate channels statistics mode for this location
          push_stream_channels_statistics;
        # query string based channel id
          push_stream_channels_path             $arg_id;
    }

    location /pub {
        # activate publisher (admin) mode for this location
          push_stream_publisher admin;

        # query string based channel id
           push_stream_channels_path            $arg_id;
           # keepalive_timeout       1800;
       # push_stream_keepalive                   on;
    }

    location ~ /sub/(.*) {
        # activate subscriber (streaming) mode for this location
          push_stream_subscriber long-polling;
      keepalive_timeout                 1800;
    #  push_stream_keepalive             on;
        # positional channel path
          push_stream_channels_path              $1;
      push_stream_ping_message_interval    10s;
    }
solderain commented 10 years ago

Add something: Just test release version 0.3.4 Found client can receive the heartbeat data follow the interval time , but both the directive 'push_stream_ping_message_text' and 'push_stream_ping_message_text' set to the location 'HTTP' , that is different from the statement for release version 0.4.0 docement.

wandenberg commented 10 years ago

Hi @solderain

the default push_stream_message_template is just ~text~, and the ping message text default is an empty string.

try to set the push_stream_message_template as "~id~|~text~|\r\n", just to test.

About the keepalive on publisher it is controlled by the nginx now, you don't have to set a specific module directive, but since you set "keepalive_timeout 0;" the nginx disable the use of keepalive.

From the nginx docs "The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections."

solderain commented 10 years ago

@wandenberg ok . I will change my configuration follow that test at once .

solderain commented 10 years ago

Test against above config , the subscriber can receive the heartbeat data and the keepalive functionality work well by correcting the configuration . (But it is very interesting ,looks like the heartbeat don't work properly if you set directive push_stream_message_template to both location 'HTTP' and 'push_stream_subscriber' when use stream mode)

wandenberg commented 10 years ago

@solderain on the configuration you sent you never set the push_stream_message_template. Could you explain better what does not worked?

solderain commented 10 years ago

@wandenberg I just try to reproduce it but it didn't appear , maybe duo to my mistake configuration . I am sorry