PDA

View Full Version : FMS client freeze when closing bad NetConnection


edgul
11-20-2007, 06:45 PM
I'm working on a network application that uses an rtmpt connection to tunnel through proxy servers to an FMS server.

I'm using an interval to check connectivity and reconnect if the client hasn't heard from the server in a while. The client freezes for up to several minutes when I call NetConnection.close() after detecting a bad connection. The client freeze is not accompanied by memory or CPU spikes, but the browser becomes unresponsive. I've seen the problem on Windows and OS X running IE 7 and Firefox 2. It doesn't seem to happen if I wait for the connection to timeout naturally, but that takes too long.

It seems like there's something wrong within the NetConnection object. Perhaps there's something I'm missing when I try to disconnect cleanly. Here's the interval function that checks/closes the connection...




/*
checkConnect is called on a 15 second interval.
It checks the value of _global.connected and takes appropriate action.
_global.connected gets set to 1 each time a Shared Object syncs from the server.
*/

public function checkConnect():Void {

if ( _global.connected == 1 ) {
// Connection is good.
// Send check in message to server
client_nc.call("handleClientCheckIn",null,_global.userdata.username);
} else if ( _global.connected == 0 ) {
// Connection is bad.
// Sending test heartbeat signal. This will update an SO that should sync back to the client
client_nc.call("handleTestHeartbeat",null, _global.userdata.id);
} else if ( _global.connected == -1 ) {
// Connection has been bad for a while. Forcing disconnect.
// Clear the interval that calls this function
clearInterval(checkInterval);
// Clear the status listener
client_nc.onStatus = null;
// Close the connection
client_nc.close();
// Undefined the NetConnection object
client_nc = null;
// Call reconnect function
reconnect();
}

// reduce value of _global.connected
_global.connected--;
}



There are definitely network problems on the client side. I have several clients at one firm, and they all seem to disconnect simultaneously. Clients at other firms have no problem. I'm working on getting that particular client to check and adjust their proxy server settings. But I'm not in control of that and I am -- or at least should be -- in control of the Flash client.