Fighting Disconnects

Options
Hello!

Our company is using Photon V3 with Client Flash SDK in test mode now. After gathering some statistics we faced a problem. Around 10-20% of our users gets disconnected (sometimes right after connect, sometimes over time). The disconnects we talking about are logged from client side when PhotonCore dispatches Event.CLOSE event. So it's not the browser closing or something else.

We wrote Server code almost from scratch (We don't use Lite or any other). Peer class have 1 simple operation for test purposes and it works fine. Server is self-hosted, running on Amazon AWS m1.small instance.

Our client code to operate with Photon looks like this:

[code2=as3]public class PhotonServer extends PhotonPeer {
private var _config:PhotonServerConfig;

private var _connectionTimeoutId:uint = 0;

public function PhotonServer() {
addEventListener(InitializeConnectionResponse.TYPE, handleInitializeConnectionResponse);
addEventListener(Event.CLOSE, handleCloseConnection);
addEventListener(IOErrorEvent.IO_ERROR, handleError);
addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleSecurityError);
addEventListener(PhotonErrorEvent.ERROR, handleError);
addResponseListener(PhotonOperationType.BACKEND, handleBackendResponse);
}

private function handleBackendResponse(data:Object):void {
try {
var requestType:String = data[PhotonOperationDataType.COMMAND_NAME];
var isSuccess:Boolean = data[PhotonOperationDataType.RESULT] == 1;
var responseData:* = data[PhotonOperationDataType.DATA];

if (requestType == null) {
requestType = "unknown";
}

if (responseData == null) {
responseData = {};
}

var photonRequest:PhotonRequest = new PhotonRequest(requestType, isSuccess, responseData);

dispatchEvent(new PhotonServerEvent(PhotonServerEvent.BACKEND_RESPONSE, photonRequest));

} catch (error:Error) {
Logger.error("fatalPhotonError", error);
}
}

private function handleSecurityError(event:SecurityErrorEvent):void {
Logger.warning("photonServerError", event.toString(), this);

dispatchEvent(new PhotonServerEvent(PhotonServerEvent.ERROR));

implementConnect();
}

private function handleError(event:Event):void {
Logger.warning("photonServerError", event.toString(), this);

dispatchEvent(new PhotonServerEvent(PhotonServerEvent.ERROR));
}

private function handleInitializeConnectionResponse(event:InitializeConnectionResponse):void {
clearConnectionTimeout();

Logger.info("photonConnected", null, this);
}

private function clearConnectionTimeout():void {
clearTimeout(_connectionTimeoutId);
}

private function handleCloseConnection(event:Event):void {
// Logger.info("photonDisconnected", null, this);

implementConnect();
}

public function initConnect(config:PhotonServerConfig):void {
_config = config;

logTryConnect();
initializeConnection(_config.url, _config.port, _config.policyPort, _config.applicationId);
}

private function implementConnect():void {
clearConnectionTimeout();

_connectionTimeoutId = setTimeout(tryConnect, 2000);
}

private function tryConnect():void {
logTryConnect();
connect();
}

private function logTryConnect():void {
Logger.info("photonTryConnect", null, this);
}
}[/code2]

There is how disconnects looks like in dashboard.
1380028695-clip-16kb.png?nocache=1

We also noticed that very often disconnected users have very high RoundTripTime and RoundTripTimeVariance. Does it mean that client lagging at that time?

Important to say, that our clients also connected to our Java server on a different port (Photon uses 4530, Java - 9777), which works just fine.

If you have any thoughts what causes this disconnects please help. Thanks in Advance.
Evgeny.

Comments

  • Tobias
    Options
    This turned into a mail conversation.
  • BesoC
    Options
    Please let me know when you find some reason for it. I'm having same dificulties with TimeoutDisconncets