Xhr/xhr_send Spam on Production Server

2018-04-19_15-31-18

I am currently having issues with Meteor. We use EC2, Phusion Passenger, and Apache to host our Production Servers. On our production website, the client is sending several xhr/xhr_send requests per second. This is causing issues and might be ultimately crashing our servers at random times throughout the day. We tried disabling websockets using process.env.DISABLE_WEBSOCKETS = 1; which did not do the trick. Does anyone know where these xhr/xhr_send requests are coming from? When I run the same codebase in localhost, these requests do not exists. From the console it looks like it is coming from sockjs which should be part of Meteor. I do not see these in other people’s Meteor websites.

Any help is much appreciated

Thank you.

My guess is that it’s failing to establish a websocket connection through your reverse proxies, and falling back to polling via XMLHttpRequests, aka xhr.

I remember having similar issues with Meteor behind nginx before till I figured out the correct config for it

I remember having similar issues with Meteor behind nginx before till I figured out the correct config for it

Do you have any suggestions on information we can read up to learn about the correct configuration to setup Meteor behind nginx?

My guess is that it’s failing to establish a websocket connection through your reverse proxies, and falling back to polling via XMLHttpRequests, aka xhr.

And thank you for the insight!

You’re most likely not handling upgrade headers correctly. In nginx it’s:

		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
		real_ip_header X-Forwarded-For;
		real_ip_recursive on;
1 Like