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

Not able to subscripbe and not geting push if upush server is another location #171

Closed ankurrai02 closed 9 years ago

ankurrai02 commented 9 years ago
      var pushstream = new PushStream({
      host: "<server ip>",
      port: "<port>",
      modes: "longpolling",
      messagesPublishedAfter: 5,
  messagesControlByArgument: true

)}

wandenberg commented 9 years ago

Hi @ankurrai02

if your push server is not on the same host and port as your html you must use JSONP to avoid cross domains javascript issues. Take a look on the example and check if your server is properly configured.

ankurrai02 commented 9 years ago

Thanks wandenberg

now i am geting push but i am geting following java script error while receiveing push with json data

SyntaxError: missing } after property list http://202.153.34.59/lp/dev_12?&tag=0&time=&eventid=&callback=PushStreamManager_0_onmessage_1422853560267&_=1422853560267 Line 2

my ngnix conf is

    location /pub {
        push_stream_publisher admin;
        set $push_stream_channel_id             $arg_id;
    }

    location ~ /lp/(.*) {
        push_stream_subscriber      long-polling;
        set $push_stream_channels_path    $1;
        push_stream_message_template                "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\"}";
        push_stream_longpolling_connection_ttl        30s;
    }

do i need to change any thing in config ?

wandenberg commented 9 years ago

Check if your published message when it is applied to message_template it still a valid json. May be needed to remove the quote on template, from ,\"text\":\"~text~\" to ,\"text\":~text~ Or escape the message to a string and unescape it on your client.

ankurrai02 commented 9 years ago

Thankyou very much Wandenberg Its working :) just a small thing my json text has converted to pjson object any idea how to convert it back to json text

wandenberg commented 9 years ago

What do you mean by pjson? Can you give me an example to be easier help you?

ankurrai02 commented 9 years ago

Hi wandenberg

i fixed it by JSON.stringify , now its working Thanks again :)