Welcome! Log In Create A New Profile

Advanced

Config help needed to create long-polling location

May 07, 2010 12:58PM
Hi All,

I'm trying to use the long polling module. I got it compiled, installed
and running:-

ian@titan:~$ nginx -V
nginx version: nginx/0.7.65
built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
configure arguments: --with-openssl=/usr/lib/ssl/ --sbin-path=/usr/sbin
--conf-path=/etc/nginx/nginx.conf
--add-module=/home/ian/sources/nginx_http_push_module-0.69
ian@titan:~$

But I can't get it configured properly. The address to write messages
to, appears not to exist whatever I do.

The key part of the configuration is this:-

server {
listen 80;
server_name coachmaster.titan.hcs;
root /home/ian/websites/coachmaster;
index index.php index.html index.htm;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
}
# now to configure the long polling
push_store_messages on;
location /publish {
push_publisher;
set $push_channel_id $arg_id;
push_message_timeout 5m;
push_max_message_buffer_length 10;
push_min_message_recipients 0;
}
# public long-polling endpoint
location /activity {
push_subscriber;
push_subscriber_concurrency broadcast;
set $push_channel_id $arg_id;
default_type text/plain;
}
}

When I post to the /publish location I get a 404 error. Always. When I
"get" from a file that exists, I get the file content.
When I post to a .php that exists, it gets run and its output is
returned, so I'm fairly confident that the trouble is in the config file
or my understanding, not the php.

This is the test script:-
<?php
$host = $_SERVER['HTTP_HOST'];
$url = "http://$host/publish?id=1234";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/json"));
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Accept: text/json"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // read data
curl_setopt($ch, CURLOPT_POST, true); // do a post
curl_setopt($ch, CURLOPT_POSTFIELDS, 'A test message');
$rec_data = curl_exec($ch);
echo "Result\n";
echo $rec_data;
?>

This is the reply:-

Result
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /publish was not found on this server.</p>
</body></html>

If you are wondering why I should do the post from php, it is because I
want to log the info posted as well, and
check that the poster is logged in properly, neither of which I can do
in JavaScript.

I would be very grateful if some kind person can spot what I'm doing
wrong - before I tear out my remaining hair!

Regards

Ian


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Config help needed to create long-polling location

hobson42 May 07, 2010 12:58PM

Re: Config help needed to create long-polling location

hobson42 May 08, 2010 09:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 136
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready