Meteor and cloudflare with causes loop of xhr requests

7/30/2015

I am writing a Meteor application that has two components - a frontend meteor app, hosted on one server, and a chat app hosted on another. The chat application uses socket.io to do the actual messaging (because I wanted to use redis pub-sub and that isn't supported by Meteor yet), and of course sockjs for the rest.

I am hosting the two on Kubernetes. At their network IPs, websockets are working.

However, I want to use Cloudflare, where websockets won't work, so I have the DISABLE_WEBSOCKETS env variable set to 1. Additionally, the transports for socket.io should have just defaulted to xhr polling.

The only problem is this:

  • when I get the conversations, the app hangs because the frontend web app is making a huge number of repeated "xhr" requests to the chat app.
  • after a while, the chat app is able to respond and send down the information after about 10 seconds, when it should have taken less than 0.5 seconds.
  • there are a huge number of sockjs xhr requests being made, whereas the number of sockjs xhr requests to the normal frontend app is small.
  • on development, this issue doesn't arise even with DISABLE_WEBSOCKETS set to 1.

On Cloudflare, I tried the following (from this page: https://modulus.desk.com/customer/portal/articles/1929796-cloudflare-configuration-with-meteor-xhr-polling): - Set "Pseudo IPv4" to "Overwrite Headers"

Is there a special Meteor configuration I need to get xhr working with cloudflare? Additionally, I have another service on the app as well, but it works completely fine. Could socket.io somehow be interfering with sockjs in the chat service?

-- user2205763
cloudflare
google-cloud-platform
kubernetes
meteor

0 Answers