Pita/etherpad-lite — Issue #200: reconnect not handled properly with disconnect triggered by javascript:window.location links
Author: dcolens
Created: 2011-11-15 13:41:39+00:00
State: open

How to trigger a disconnect is easy : put etherpad in an iframe and add a link in the parent document with href such as : javascript:window.location='mailto:username@example.com';" (one can use xmpp,... uri too)

Sample repro code :

```html

Click Me

```

When you click on "Click Me" it will close the socket-io connection in Chrome (17.0.932.0 dev) and firefox (8.0) and the "Disconnected" message shows up on the embedded pad which is very annoying if one has multiple similar links on the parent frame (and assuming one has no control on the parent frame content).

Browsing the code, it seems the reconnecting code is commented out, also handleSocketClosed is called with true as an argument instead of an object, changing the argument to and object such as {'reconnect' : true} triggers some of the reconnecting code, but setUpSocket() crashes because handleSocketClosed destroyed socket just before.

Using "window.location.reload()" in handleSocketClosed does the job but is not a very nice way to handle such a situation (and it is buggy in firefox).