Web page refreshes continuosuly over slow internet connection

I have meteor application using blaze deployed on digitalocean droplet. I notice that when my Internet connection is slow (3G or even at-times 4G in India), the web page refreshes continuously. In the chrome developer tools I can see websocket request is made every 10-20 seconds. Every websocket request fetches the subscribed data. I have subscribed to node database and fetching first 20 records when page loads. Each node record is 500-1000 bytes.

On fast Internet connection, I can see in developer tools that websocket request is made only once and then there is ping and pong exchanges between server and client. But on slow Internet connection there are no ping/pong exchanges, rather the entire websocket request is made again every 10-20 seconds.

Any help would be greatly appreciated. Thanks.

  • Use an India-located VPS provider.
  • Make sure you are accessing your site over https & wss
  • Make sure you’re using oplog.
  • Most of our team is in US, so we cant use VPS in India.
  • We are using https and wss
  • We have set oplog in mongodb config file (via options oplogSizeMB: 300, replSetName: meteor). Is there a easy way to see if meteor is indeed using oplog. Iam looking at Internet to figure out a way, but havent found conclusive solutions yet.

Thanks

I guess that makes sense :joy:

But why page refresh under slow connection? Iam sure lot of people must be using their app on slow connections over 3G and so on. So why Iam experiencing page refresh?

Thanks

  1. Are you on an Android device? If so, which one?
  2. Who is the internet provider?

Traffic management and device compatibility are the two likely culprits. That means the Internet provider may abruptly close or incorrectly reroute connections; your particular version of browser does not work with the 2014-era SockJS fork that Meteor uses; that there’s something idiosyncratic about your server configuration that works with modern desktop devices and phones but not with the particular device you use.

There’s an idea in experimental biology that you should try changing as much as possible about your experiment and see if it works, instead of changing one thing at a time. Changing one thing at a time is too slow! My recommendation is to try to run your application on an Indian VPS using meteor run, without https, so you get logs, and see what happens when you access it from an iOS 12 device.

Thanks for the reply.

Iam using laptop with chrome browser on Ubuntu.Other folks in India have experienced similar problems on their laptop. I have tested both chrome and firefox and experienced the problem on both these browsers.

Folks in USA dont experience this problem. I think its poor connection with digitalocean VM to India that is causing the problem. When there is high ping latency and packet loss to the server I guess the application doesnt work properly and the page refreshes.

But packet loss of 1-2% is not uncommon over poor 3G connection. Could I be doing something wrong in my application that makes it perform incorrectly under packet loss and high ping latency.

Thanks

No, I don’t think so. If it works for you, it works for you.

For straightforward, one-way REST sites, there are very affordable near-cache solutions that make those sites work well around the world.

You can certainly do something similar by using a Indian VPS. It will improve things a lot!

can you share any logs or code? Or a list of packages you use? We use our apps with flaky connections all the time - there’s nothing I can think of in meteor that would refresh your app. If you lose connection, you just lose data - it shouldn’t cause a refresh. Specifically, what happens immediately before the refresh, and can you stick a breakpoint on the load/unload event of the page, see what’s triggering it

Thanks for reply.

I dont see anything special in logs. Some of the packages I use are babel, async, aws-sdk, bootstrap, tcp-ping, ip, net-snmp, p-all, ssh2, scp2, etc.

What happens is application makes a websocket request. On faster Internet The websocket request completes and then I can see ping/pong exchanges every 15-20 seconds.

On slower Internet, the websocket does not complete it seems, or atleast there are ping/pong exchanges, and so app makes a new websocket request every 15-20 seconds, causing the webpage to reload.

Why is websocket request not completing on slow Internet. Even on pages which dont have much data subscribed I can see page reloads. Should I increase the timeout for websocket request? If so what is the correct way to do that?

Thanks

A few thoughts:

  1. that’s an odd list of packages, can you paste the contents of your package.json and .meteor/packages in here
  2. A flaky connection shouldn’t cause a refresh, I suspect either your code, or a package is refreshing on reconnect; in a browser where this doesn’t happen, what happens if you put Meteor.disconnect(); Meteor.reconnect(); in the console?
  3. you need to set a breakpoint on the load/unload event and see what triggers the refresh
  4. The websocket not completing isn’t necessarily a problem, DDP falls back on XHR and long polling in the case that it can’t establish a websocket - do you see any XHR requests?
1 Like

Thanks for reply. Here is package.json

    "@babel/runtime": "^7.2.0",
    "async": "^2.6.2",
    "aws-sdk": "^2.308.0",
    "babel-runtime": "^6.26.0",
    "bluebird": "^3.5.1",
    "body-parser": "^1.18.2",
    "bootbox": "^4.4.0",
    "bootstrap-alerts": "^1.2.2",
    "bootstrap-select": "^1.12.4",
    "bootstrap-slider": "^9.10.0",
    "buffer": "^5.0.8",
    "core-decorators": "^0.20.0",
    "escape-html": "^1.0.3",
    "google-auth-library": "^0.11.0",
    "google-id-token-verifier": "^0.2.3",
    "googleapis": "^22.2.0",
    "gps-util": "^1.0.1",
    "html-to-text": "^4.0.0",
    "ip": "^1.1.5",
    "jquery": "^2.2.3",
    "mac-address": "^0.3.0",
    "mailparser": "^2.1.0",
    "math": "0.0.3",
    "meteor-node-stubs": "^0.4.1",
    "mikronode": "^2.3.6",
    "moment": "^2.19.1",
    "moment-timezone": "^0.5.14",
    "mongodb_s3_backup": "^0.0.8",
    "net-snmp": "^1.2.0",
    "node-email-reply-parser": "^0.1.1",
    "node-ssh": "^5.0.0",
    "nodemailer": "^4.4.0",
    "p-all": "^1.0.0",
        "p-any": "^1.1.0",
    "p-series": "^1.1.0",
    "p-wait-for": "^1.0.0",
    "p-whilst": "^1.0.0",
    "ping": "^0.2.2",
    "querystring": "^0.2.0",
    "request": "^2.87.0",
    "request-promise-native": "^1.0.5",
    "rxjs": "^5.5.7",
    "scp2": "^0.5.0",
    "simpl-schema": "^0.4.0",
    "ssh2": "^0.5.5",
    "stripe": "^5.3.0",
    "tcp-ping": "^0.1.1",
    "underscore": "^1.8.3",
    "uservoice": "^0.4.1"

And .meteor/packages

insecure@1.0.7
less@2.8.0
jquery@1.11.10
accounts-google@1.3.2
mizzao:user-status
service-configuration@1.0.11
peerlibrary:aws-sdk
email@1.2.3
mrt:moment
mrt:moment-timezone
percolatestudio:synced-cron

accounts-ui@1.3.1
mrt:cookies
thepumpinglemma:cookies
froatsnook:sleep

percolate:find-from-publication

tmeasday:publish-counts
reactive-var@1.0.11
sacha:spin
reywood:publish-composite

standard-minifier-css@1.5.2
standard-minifier-js@2.4.0
ecmascript@0.12.4
shell-server@0.4.0
google-config-ui@1.0.1
matb33:collection-hooks
summernote:summernote
dynamic-import@0.5.0
mouse0270:bootstrap-notify
kookoskar:bootstrap-select
es5-shim@4.8.0
mdg:validated-method
aldeed:collection2-core@2.0.1
kadira:blaze-layout
kadira:flow-router
didericis:callpromise-mixin
dburles:google-maps
dburles:collection-helpers
meteorhacks:picker
tap:i18n
ostrio:files
momentjs:moment
http

Do you suspect any package is causing this issue?

I have not been able to reproduce the problem in last 3 days, so cant verify other things you have mentioned like Meteor.disconnect, setting breakpoint in load/unload, and XHR requests.

Thanks