Nginx推送流无法正常工作

时间:2015-09-25 06:07:43

标签: php nginx

Nginx推送流不起作用。来自/ channel / one的空答案。

 location ~ /pub {
                 push_stream_publisher               admin;
                 push_stream_channels_path    $arg_id;
                 push_stream_store_messages         on;
                 allow          127.0.0.1;
              }

        location ~ /channel/(.*) {
                 push_stream_subscriber         long-polling ; 
                 push_stream_channels_path                 $1;
                 push_stream_longpolling_connection_ttl    10s;   push_stream_last_received_message_time  $arg_time; 
                push_stream_last_received_message_tag     $arg_tag; 

                push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"tag\":\"~tag~\",\"time\":\"~time~\",\"text\":~text~}";   

              }

PHP:

$ch = curl_init('http://127.0.0.1/pub?id='.$channel_id);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($message));
curl_exec($ch);
curl_close($ch);

Javascript - http://pastebin.com/afFmhN4J

怎么办?请回答!

1 个答案:

答案 0 :(得分:0)

If this is pertaining to HTTP/2, NGINX(v1.9.5) does not support push-stream as of yet.