LearnBoost/socket.io — Issue #691: Losing connection/reconnect issue in WP7 using 'htmlfile' transport
Author: cielo
Created: 2011-12-17 23:52:58+00:00
State: open

I have tried using socket.io with mobile devices.

IPhone seems to work fine and it uses Websocket transport.

I also tried Window Phone 7 (with mango) which works fine, however there is a problem here.

When user switches to the other application, the browser seem to stop sending and receiving heartbeats
(WP7 browser (IE7 i think) does not have Websocket support yet, so it uses htmlfile transport)

After a period of time, the server thinks the WP7(Window Phone 7) has disconnected and disconnect it from the sockets list.
(removes all socket data related to that WP7 , including handshaken data)

When user re-open up the browser that already has a page open, and tries to communicate with the server, the server does receive the htmlfile data from WP7, but discards it because client's id is not found in the handshaken data list (which is deleted already).

Below is the code that the server discards the transport

https://github.com/LearnBoost/socket.io/blob/master/lib/manager.js#L628

```javascript
var transport = new transports[data.transport](this, data, req)
, handshaken = this.handshaken[data.id];
if (transport.disconnected) { ///does not go in here
}
if (handshaken) { //does not go in here
///many lines of code not shown
} else { // goes in here
if (transport.open) { //does not go in here
transport.error('client not handshaken', 'reconnect');
}
transport.discard();
}
```

The problem is that transport.open seems to return false all the time, and

transport.error('client not handshaken', 'reconnect');

line does not get executed.

Therefore, server just discards the request from WP7, and client does not get any single error message from the server, making it not trying to reconnect to the server. (which it should try reconnect/re-authorize)

Should that `transport.open` always return false?

What would be a right way for client to reconnect/re-authorize?