开发者

NowJS manually initiating a new connection after a lost connection

i have a case where clients connect to a node.js server running nowjs and remain connected for a fairly long time (about 30 minutes). on some browsers though the connection gets dropped after a while and the client disconnects.

i implemented a disconnect handler on the client side like this:

now.core.on('disconnect', function () {
    // we should reconnect here, maybe after a short timeout
});

what i am unclear about is how exactly to trigger a reconnect. this might be something blatantly obvious to experienced users but i didn't manage to figure this out.

the now.js script ini开发者_Python百科tializes on page load and after that i can use the now object, but i can't figure out how to repeat this process without reloading the page.

thanks!


Yes, automatic reconnects are supported with NowJS, as of v0.6.1.

The website needs to be updated, but there's a blog post detailed the implementation of reconnects in NowJS here.


The documentation on the site is a bit outdated -- as of version 0.6.1 (released on June 10; current version on npm), automatic reconnects are supported. It mostly just takes advantage of the automatic reconnect feature in Socket.IO v0.6.18, although there were a few other miscellaneous tweaks that had to be made (there's apparently a blog post about it at blog.nowjs.com).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜