Set environment variable to stop browsers from using websockets.

This commit is contained in:
David Glasser
2013-05-30 11:49:28 -07:00
parent de6543b712
commit debbaa2db2
2 changed files with 19 additions and 3 deletions

View File

@@ -6,6 +6,11 @@
packages can be used to perform an OAuth exchange without creating an
account and logging in. #1024
* If you set the `DISABLE_WEBSOCKETS` environment variable, browsers will not
attempt to connect to your app using Websockets. Use this if you know your
server environment does not properly proxy Websockets to reduce connection
startup time.
* Make `Meteor.defer` work in an inactive tab in iOS. #1023
* Allow new `Random` instances to be constructed with specified seed. This

View File

@@ -16,8 +16,9 @@ Meteor._DdpStreamServer = function () {
// set up sockjs
var sockjs = Npm.require('sockjs');
self.server = sockjs.createServer({
prefix: '/sockjs', log: function(){},
var serverOptions = {
prefix: '/sockjs',
log: function() {},
// this is the default, but we code it explicitly because we depend
// on it in stream_client:HEARTBEAT_TIMEOUT
heartbeat_delay: 25000,
@@ -28,7 +29,17 @@ Meteor._DdpStreamServer = function () {
// combining CPU-heavy processing with SockJS termination (eg a proxy which
// converts to Unix sockets) but for now, raise the delay.
disconnect_delay: 60 * 1000,
jsessionid: false});
jsessionid: false
};
// If you know your server environment (eg, proxies) will prevent websockets
// from ever working, set $DISABLE_WEBSOCKETS and SockJS clients (ie,
// browsers) will not waste time attempting to use them.
// (Your server will still have a /websocket endpoint.)
if (process.env.DISABLE_WEBSOCKETS)
serverOptions.websocket = false;
self.server = sockjs.createServer(serverOptions);
self.server.installHandlers(__meteor_bootstrap__.httpServer);
// Support the /websocket endpoint