Naively connecting to real-time socket.io.

This commit is contained in:
Samuel Clay 2013-03-17 14:41:29 -07:00
parent faa57db7c9
commit bc59711fa3
3 changed files with 5 additions and 33 deletions

View file

@ -6,7 +6,7 @@ global
ca-base /srv/newsblur/config/certificates
crt-base /srv/newsblur/config/certificates
log 127.0.0.1 local0 notice
log 127.0.0.1 local1 info
# log 127.0.0.1 local1 info
defaults
log global

4
fabfile.py vendored
View file

@ -181,8 +181,8 @@ def post_deploy():
cleanup_assets()
@parallel
def deploy():
deploy_code(copy_assets=True)
def deploy(fast=False):
deploy_code(copy_assets=True, fast=fast)
def deploy_full():
deploy_code(copy_assets=True, full=True)

View file

@ -3877,18 +3877,12 @@
var server = window.location.protocol + '//' + window.location.hostname;
var port = _.string.startsWith(window.location.protocol, 'https') ? 8889 : 8888;
this.socket = this.socket || io.connect(server, {
"reconnection delay": 5000,
"connect timeout": 5000,
"reconnection delay": 2000,
"connect timeout": 2000,
"port": NEWSBLUR.Globals.debug ? port : 80
});
// this.socket.refresh_feeds = _.debounce(_.bind(this.force_feeds_refresh, this), 1000*10);
this.socket.on('reconnect_error', _.bind(function() {
this.retry_socketio_connect();
}, this));
this.socket.on('reconnect_failed', _.bind(function() {
this.retry_socketio_connect();
}, this));
this.socket.on('connect', _.bind(function() {
var active_feeds = this.send_socket_active_feeds();
// NEWSBLUR.log(["Connected to real-time pubsub with " + active_feeds.length + " feeds."]);
@ -3934,8 +3928,6 @@
this.setup_feed_refresh();
// $('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating every 60 sec'));
$('.NB-module-content-account-realtime').attr('title', 'Updating sites every ' + this.flags.refresh_interval + ' seconds...').addClass('NB-error');
this.retry_socketio_connect();
}, this));
this.socket.on('error', _.bind(function() {
NEWSBLUR.log(["Can't connect to real-time pubsub."]);
@ -3943,31 +3935,11 @@
// $('.NB-module-content-account-realtime-subtitle').html($.make('b', 'Updating every 60 sec'));
$('.NB-module-content-account-realtime').attr('title', 'Updating sites every ' + this.flags.refresh_interval + ' seconds...').addClass('NB-error');
_.delay(_.bind(this.setup_socket_realtime_unread_counts, this), 60*1000);
this.retry_socketio_connect();
}, this));
}
},
retry_socketio_connect: function() {
var port = _.string.startsWith(window.location.protocol, 'https') ? 8889 : 8888;
console.log('Real-time connection failed. Tried port:', this.socket.socket.options.port);
if (this.socket.socket.options.port == port) {
this.socket.socket.options.port = 80;
} else {
this.socket.socket.options.port = port;
}
this.counts.socket_reconnects += .5;
clearTimeout(this.cache.socketio_reconnect);
this.cache.socketio_reconnect = _.delay(_.bind(function() {
this.socket.socket.connect();
}, this), this.counts.socket_reconnects * 1000);
},
send_socket_active_feeds: function() {
if (!this.socket) return;