Disable unsupported SockJS transports

Because our authentication system reads cookies from the initial
connection attempt, several SockJS transports can't be used.

(imported from commit 34b9571225d39072985b8223fb12c43c7235841f)
This commit is contained in:
Zev Benjamin
2013-10-08 16:10:27 -04:00
parent ca16644152
commit 3c73468ba8
2 changed files with 6 additions and 3 deletions

View File

@@ -12,7 +12,9 @@ function Socket(url) {
this._is_unloading = true; this._is_unloading = true;
}); });
this._sockjs = new SockJS(url); this._supported_protocols = ['websocket', 'xdr-streaming', 'xhr-streaming',
'xdr-polling', 'xhr-polling', 'jsonp-polling'];
this._sockjs = new SockJS(url, null, {protocols_whitelist: this._supported_protocols});
this._setup_sockjs_callbacks(this._sockjs); this._setup_sockjs_callbacks(this._sockjs);
} }
@@ -119,7 +121,7 @@ Socket.prototype = {
setTimeout(function () { setTimeout(function () {
blueslip.info("Attempting reconnect."); blueslip.info("Attempting reconnect.");
that._sockjs = new SockJS(that.url); that._sockjs = new SockJS(that.url, null, {protocols_whitelist: that._supported_protocols});
that._setup_sockjs_callbacks(that._sockjs); that._setup_sockjs_callbacks(that._sockjs);
}, wait_time); }, wait_time);
} }

View File

@@ -147,6 +147,7 @@ def respond_send_message(chan, method, props, data):
200, 'send_message', connection.session.user_profile.email) 200, 'send_message', connection.session.user_profile.email)
sockjs_router = sockjs.tornado.SockJSRouter(SocketConnection, "/sockjs", sockjs_router = sockjs.tornado.SockJSRouter(SocketConnection, "/sockjs",
{'sockjs_url': 'https://%s/static/third/sockjs/sockjs-0.3.4.js' % (settings.EXTERNAL_HOST,)}) {'sockjs_url': 'https://%s/static/third/sockjs/sockjs-0.3.4.js' % (settings.EXTERNAL_HOST,),
'disabled_transports': ['eventsource', 'htmlfile']})
def get_sockjs_router(): def get_sockjs_router():
return sockjs_router return sockjs_router