Meteor XHR requests are repeatedly sent

451 views
Skip to first unread message

Lloyd Henning

unread,
May 18, 2014, 10:16:50 AM5/18/14
to phusion-...@googlegroups.com
I'm running a Meteor app with passenger in nginx integration mode and everything works except for when sockjs falls back to XHR requests.

When connecting to an app with a browser that doesn't support websockets (e.g. a <4.4 Android browser) the browser repeatedly creates new connections. This doesn't happen with the development server, or when running passenger standalone.

In my access.log I have constant stream of connections being made

...
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "GET /sockjs/info?cb=0donfkxx7n HTTP/1.1" 200 118 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/190/e8yys5ia/xhr HTTP/1.1" 200 53 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/190/e8yys5ia/xhr_send HTTP/1.1" 204 0 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/190/e8yys5ia/xhr HTTP/1.1" 200 255 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/190/e8yys5ia/xhr HTTP/1.1" 200 40 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/190/e8yys5ia/xhr_send HTTP/1.1" 404 78 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "GET /sockjs/info?cb=tz5_75c88r HTTP/1.1" 200 130 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/995/qp8j5g8q/xhr HTTP/1.1" 200 44 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/995/qp8j5g8q/xhr_send HTTP/1.1" 204 0 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/995/qp8j5g8q/xhr HTTP/1.1" 200 254 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/995/qp8j5g8q/xhr_send HTTP/1.1" 204 0 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
192.168.1.107 - - [18/May/2014:15:09:45 +0100] "POST /sockjs/995/qp8j5g8q/xhr HTTP/1.1" 200 207 "http://ng/" "Mozilla/5.0 (Linux; U; Android 2.3.7; en-gb; Nexus One Build/GRK39F; CyanogenMod-7.2.0) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile
...

I've tried this with just the leaderboard example behind nginx. I guess you made need a non-websocket capable browser to test it, as I'm not sure how you can force sockjs to use XHR.

Thanks,

Lloyd


P.S. Passenger makes deploying meteor sites fun, I hope I can fix this problem.

Tinco Andringa

unread,
May 19, 2014, 6:00:28 AM5/19/14
to phusion-...@googlegroups.com
Hi Lloyd,

Thanks for the compliment, making deploying fun certainly is our goal :)

About the problem, it's hard for me to guess what's going on without
more information. Something about your production environment is
making Meteor behaving differently. Finding the root would probably
require you to carefully study the networking tab in your browser to
find out what's going on. Since you're on Android perhaps that's a bit
hard. I'd suggest studying sockjs to find out how to force it to use
XHR and then debug it on a desktop browser :)

Kind regards,
Tinco
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/872e846c-3f27-4802-98d5-2267ac8a3a24%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Phusion | Web application deployment, scaling and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Lloyd Henning

unread,
May 19, 2014, 6:58:07 AM5/19/14
to phusion-...@googlegroups.com
Thanks for the reply, I've looked at how to turn off websockets on a Meteor application, and it requires the DISABLE_WEBSOCKETS environmental variable to be set. So in terms of passenger/nginx config my server config file looks like this 

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

    charset utf-8;

    passenger_enabled       on;
    passenger_set_cgi_param MONGO_URL mongodb://localhost:27017/kar;
    passenger_set_cgi_param ROOT_URL http://ng;
    passenger_set_cgi_param DISABLE_WEBSOCKETS 1;
}

I'm trying it with the leaderboard example project (a bundled meteor app) and am running Phusion Passenger version 4.0.40, Meteor 0.8.1.2 on Arch Linux 64 bit.

I can now see in the networking tab on chrome that it makes a few successful XHR requests and then receives a 404.


It seems similar to this issue posted by Hongli https://groups.google.com/forum/#!topic/meteor-talk/SVz1-bzinfY 

Lloyd Henning

unread,
May 19, 2014, 7:43:45 AM5/19/14
to phusion-...@googlegroups.com
I'm thinking that it may be to do with sticky sessions, which Meteor/sockjs requires. Which might cause a problem with XHR requests. I've tried enabling sticky sessions via

      passenger_set_cgi_param PASSENGER_STICKY_SESSION true;

But no luck. I'm also limiting the number of processes with

      passenger_max_pool_size 1;

But again it doesn't seem to have any effect.

Tinco Andringa

unread,
May 26, 2014, 5:05:33 AM5/26/14
to phusion-...@googlegroups.com
That should have done it, stange, could you watch the meteor (nodejs)
process id and see if it changes in between requests? It could be that
it's exitting for whatever reason and loses the session. Either that
or something else makes it lose the session. With
passenger_max_pool_size set to 1 I'm a bit stumped as to what could be
causing it :)

Kind regards,
Tinco
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/28fd9f2c-f32e-4964-ba2e-9eac2554ecec%40googlegroups.com.

Hongli Lai

unread,
May 29, 2014, 3:48:33 PM5/29/14
to phusion-passenger
I confirm this issue. It only happens when WebSockets are disabled. It
seems the request finishes immediately, and then Meteor tries
immediately again.
> To view this discussion on the web visit https://groups.google.com/d/msgid/phusion-passenger/CAGW%3D8RoSd0Wi3hPDCFwwe-_ou_%2BxAO%3DjEM-J0B%2Bwk4auWdLt9w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Phusion | Web Application deployment, scaling, and monitoring solutions

Hongli Lai

unread,
May 29, 2014, 3:54:58 PM5/29/14
to phusion-passenger
I've filed an issue at the issue tracker:
https://github.com/phusion/passenger/issues/1198
Let's move the discussion there.
Reply all
Reply to author
Forward
0 new messages