Issue Client not receiving published messages from Nodejs server with nginx to proxy to call. but client can receive published message from Node.js server without nginx to proxy to call

205 views
Skip to first unread message

高财吴

unread,
May 16, 2013, 3:45:07 AM5/16/13
to faye-...@googlegroups.com
I ran the node.js server attach faye on 8030 port.

I ran nginx server on 80 port.

I use nginx as proxy server and the client request will redirect to node.js server by nginx proxy call.

I have the below question.

1: If the client send request to node.js server by nginx to proxy call, the client can't receive the published messages. I can see the below error in the
console

        '2013-05-16 15:35:12 [ERROR] [Faye.NodeAdapter] Received request with no message: curl -X GET 'http://otatest.joyplus.tv/uploadApk''.
 
        var client = new Faye.Client('http://otatest.domain.tv/uploadApk');   
                    var subscription = client.subscribe('/'+channel, function(message) {
                       alert("Url:"+message.file_url);
                       alert("file key:"+message.file_key);
                    });


2: If the client direct send request to node.js server I can receive the published messages from Node server.

             var client = new Faye.Client('http://otatest.domain.tv:8030/uploadApk');   
                    var subscription = client.subscribe('/'+channel, function(message) {
                       alert("Url:"+message.file_url);
                       alert("file key:"+message.file_key);
                    });



The below is nginx conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http{
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
   client_header_buffer_size 10k;
   access_log  /etc/nginx/access.log  main;
   underscores_in_headers on;
#  keepalive_timeout 3600;
 
  upstream otatest {
    keepalive 120;
    server 127.0.0.1:8030 max_fails=3 fail_timeout=30s;
  }


server {
                listen          80;
                server_name     otatest.domain.tv;
                location / {
                        index   index.html index.php index.jsp index.htm;
                        proxy_pass              http://otatest;
                        proxy_redirect          off;
                        proxy_set_header        Host    $host;
                        proxy_set_header        X-Real-IP       $remote_addr;
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_http_version 1.1;
                        proxy_set_header Connection "";
                        #proxy_connect_timeout  90;
                        #proxy_send_timeout     90;
                        #proxy_read_timeout     90;
                        #proxy_buffers          32 4K;
                }
 }



}



高财吴

unread,
May 16, 2013, 3:55:29 AM5/16/13
to faye-...@googlegroups.com
 
Also the nodejs server uses express and faye is attached to that and listen 8030 port.


James Coglan

unread,
May 16, 2013, 4:07:00 AM5/16/13
to faye-...@googlegroups.com
On 16 May 2013 08:45, 高财吴 <long7...@gmail.com> wrote:
1: If the client send request to node.js server by nginx to proxy call, the client can't receive the published messages. I can see the below error in the
console

        '2013-05-16 15:35:12 [ERROR] [Faye.NodeAdapter] Received request with no message: curl -X GET 'http://otatest.joyplus.tv/uploadApk''.

I'm not an expert on nginx config but this error means that the Faye server was expecting a message to be in the query string or entity body (probably query string since this is a GET), but the query string was empty. Seems like something not getting forwarded properly by nginx. 

高财吴

unread,
May 16, 2013, 4:51:24 AM5/16/13
to faye-...@googlegroups.com
Hi James,

Thanks for quick response.

I add the below code in the  client and server. it is ok. the client is javascript.  but I have the question how to simulator the behavoir in the android or java?

client.disable('eventsource');
client.disable('websocket');


Thanks.


在 2013年5月16日星期四UTC+8下午4时07分00秒,James Coglan写道:

James Coglan

unread,
May 16, 2013, 5:15:19 AM5/16/13
to faye-...@googlegroups.com
On 16 May 2013 09:51, 高财吴 <long7...@gmail.com> wrote:
I add the below code in the  client and server. it is ok. the client is javascript.  but I have the question how to simulator the behavoir in the android or java?

client.disable('eventsource');
client.disable('websocket'); 

If disabling these works it probably means nginx is corrupting WebSocket or EventSource requests. Which version of nginx are you using? 

高财吴

unread,
May 16, 2013, 5:23:39 AM5/16/13
to faye-...@googlegroups.com
Hi James,

I used nginx version: nginx/1.4.1.

Thanks.

在 2013年5月16日星期四UTC+8下午5时15分19秒,James Coglan写道:

James Coglan

unread,
May 16, 2013, 5:28:15 AM5/16/13
to faye-...@googlegroups.com
On 16 May 2013 10:23, 高财吴 <long7...@gmail.com> wrote:
I used nginx version: nginx/1.4.1.

That should work, but maybe there are proxy settings I don't know about that break WebSockets. 

James Coglan

unread,
May 16, 2013, 5:55:03 AM5/16/13
to faye-...@googlegroups.com
The settings you need are here:


I've actually got a WebSocket echo server running at ws://tmp1.jcoglan.com right now using this config:

server {
  listen      80;
  server_name tmp1.jcoglan.com;

  location / {
    proxy_pass http://localhost:4180;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

高财吴

unread,
May 16, 2013, 6:59:56 AM5/16/13
to faye-...@googlegroups.com
 Hi James,

It is ok now.

Thanks.

在 2013年5月16日星期四UTC+8下午5时55分03秒,James Coglan写道:
Reply all
Reply to author
Forward
0 new messages