Answer a question

I'm running a bundled Meteor app with passenger in nginx integration mode and everything works except for when sockjs falls back to XHR requests.

I get this behaviour in my own apps and the leaderboards example (I haven't tested other examples).

You can test it by disabling web sockets using the DISABLE_WEBSOCKETS environmental variable.

My nginx config for the site looks like this

server
{
    server_name             ng;
    root                    /var/www/mysitename/public;

    charset utf-8;

    passenger_enabled       on;
    passenger_set_cgi_param MONGO_URL mongodb://localhost:27017/mydbname;
    passenger_set_cgi_param ROOT_URL http://mysitename;
    passenger_set_cgi_param DISABLE_WEBSOCKETS 1;
    passenger_set_cgi_param PASSENGER_STICKY_SESSION true;
}

Then when I go to the site and open the network panel in the developer console on Chrome I get the errors like these

...
POST http://mysitename/sockjs/158/ck8pi__5/xhr_send 404 (Not Found)
POST http://mysitename/sockjs/519/4hgc4rgr/xhr_send 404 (Not Found) 
POST http://mysitename/sockjs/672/6gq99fp5/xhr_send 404 (Not Found) 
POST http://mysitename/sockjs/682/sx0e2w_v/xhr_send 404 (Not Found)
...

Essentially it keeps on creating new connections, like it is unable to continue existing ones, this appears to only happen with XHR requests, not websockets as I guess XHR require the sticky session state.

But I have enabled sticky sessions (PASSENGER_STICKY_SESSION environmental variable) and am seeing the session cookie in the resources pane, but it still has the same 404 problem.

I'm using Phusion Passenger version 4.0.40 and Meteor 0.8.1.2 on Arch Linux 64 bit.

Answers

Phusion Passenger author here. This is caused by an issue in Phusion Passenger which is documented in detail in Github issue 1198. The goal is to make all this work in the next version, 4.0.45.

Sticky sessions are necessary. We will add documentation regarding Meteor and the need to enable sticky sessions.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐