Error In JSONP

64 views
Skip to first unread message

Dmitry Tereshchenko

unread,
Sep 20, 2015, 1:04:55 PM9/20/15
to nginxpushstream
Hello!

nginx after the upgrade and install a fresh version of push stream module the error occurred. I'm using Long-polling JSONP, the client listens two channels. When sending a message to one of them, everything works fine, but if a server response contains messages from different channels appears JSON syntax error: there is no comma between the messages and the client can not read a JSON. I've been using a very old version and everything worked fine, is there any way to fix it?

Wandenberg Peixoto

unread,
Sep 20, 2015, 7:44:01 PM9/20/15
to nginxpu...@googlegroups.com

Are you using JSONP or just long polling?
Send your configuration and examples on how to reproduce the problem.

When using JSONP the comma is added by the module.
On long polling you have to add the comma on message and footer templates, if you want to, since is not mandatory to the message be a valid javascript object.

On Sep 20, 2015 14:04, "Dmitry Tereshchenko" <deme...@livechat.su> wrote:
Hello!

nginx after the upgrade and install a fresh version of push stream module the error occurred. I'm using Long-polling JSONP, the client listens two channels. When sending a message to one of them, everything works fine, but if a server response contains messages from different channels appears JSON syntax error: there is no comma between the messages and the client can not read a JSON. I've been using a very old version and everything worked fine, is there any way to fix it?

--
You received this message because you are subscribed to the Google Groups "nginxpushstream" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nginxpushstre...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dmitry Tereshchenko

unread,
Sep 21, 2015, 3:27:35 AM9/21/15
to nginxpushstream
The error occurs when the response contains messages from different channels.

Example response:

PushStreamManager_0_onmessage_1442818993956([{"id":152806,"channel":"1","text":"[1,[974384,0,0,\"10:03:01\",\"test\",[1286374],{}]]","tag":"1","time":"Mon, 21 Sep 2015 07:03:01 GMT"}{"id":3,"channel":"9a3100empn3r38q7q3fkvqge91","text":"[1,[1,1,0,\"10:03:00\",\"test\",[1],{}]]","tag":"1","time":"Mon, 21 Sep 2015 07:03:00 GMT"},{"id":4,"channel":"9a3100empn3r38q7q3fkvqge91","text":"[1,[1,1,0,\"10:03:00\",\"test\",[1],{}]]","tag":"2","time":"Mon, 21 Sep 2015 07:03:00 GMT"}]);

If all messages on a single channel, everything works correctly.

nginx version: nginx/1.6.2
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/root/nginx-1.6.2/debian/modules/nginx-auth-pam --add-module=/root/nginx-1.6.2/debian/modules/nginx-dav-ext-module --add-module=/root/nginx-1.6.2/debian/modules/nginx-echo --add-module=/root/nginx-1.6.2/debian/modules/nginx-upstream-fair --add-module=/root/nginx-1.6.2/debian/modules/ngx_http_substitutions_filter_module --add-module=/root/nginx-1.6.2/debian/modules/nginx-push-stream-module

http {
...

        push_stream_shared_memory_size                100m;
        push_stream_max_channel_id_length             50;
        push_stream_max_messages_stored_per_channel   100;
   
        # message ttl
        push_stream_message_ttl                       5m;
   
        # ping frequency
        push_stream_ping_message_interval             1s;
   
        # 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;

        # wildcard
        push_stream_wildcard_channel_prefix         "broad_";
        push_stream_wildcard_channel_max_qtd        3;

        push_stream_authorized_channels_only        off;

        push_stream_allowed_origins                 "*";
...
}

server {
...
    chunked_transfer_encoding off;

    location /pub {
        push_stream_publisher admin;
        allow  127.0.0.1;

        push_stream_store_messages              on;
        push_stream_channels_path               $arg_id;
        client_max_body_size                    32k;
        client_body_buffer_size                 32k;
    }

    location ~ /lp/(.*) {
        push_stream_subscriber                  long-polling;
        push_stream_channels_path          $1;
        push_stream_last_received_message_tag   $arg_tag;
        push_stream_last_received_message_time  $arg_time;
        push_stream_longpolling_connection_ttl  30s;
        default_type                                "text/html; charset=utf-8";
        push_stream_message_template                "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\",\"tag\":\"~tag~\",\"time\":\"~time~\"}";
    }
...
}

Wandenberg Peixoto

unread,
Sep 21, 2015, 9:53:53 AM9/21/15
to nginxpu...@googlegroups.com
Thanks. I will check.

--

Wandenberg Peixoto

unread,
Oct 5, 2015, 10:58:29 PM10/5/15
to nginxpu...@googlegroups.com
Hi Dimitry,

can you check if this commit b5db1acb613995e924357f1bc566d055ada3b4a4 completely solved the problem?

Regards,
Wandenberg

Wandenberg Peixoto

unread,
Oct 5, 2015, 11:11:14 PM10/5/15
to nginxpu...@googlegroups.com
Hi Dimitry,

can you check if this commit b5db1acb613995e924357f1bc566d055ada3b4a4 completely solved the problem?

Regards,
Wandenberg
On Mon, Sep 21, 2015 at 10:53 AM, Wandenberg Peixoto <wande...@gmail.com> wrote:

Dmitry Tereshchenko

unread,
Oct 6, 2015, 6:19:05 AM10/6/15
to nginxpushstream
The problem is solved, thank you!

воскресенье, 20 сентября 2015 г., 20:04:55 UTC+3 пользователь Dmitry Tereshchenko написал:
Reply all
Reply to author
Forward
0 new messages