Search code examples
actionscript-3websocketflashflashdevelop

Flash WebSocket Disconnect


I'm using AS3WebSocket module to connect web sockets. It works well when I launch flash locally (flash file is marked as trusted in global settings).

But when I open server page with flash, it doesn't work. I've no error messages, just "disconnect" in log.

WinServer2012, IIS, ASP.NET MVC4

Here are logs:

ws init begin: ws://www.sample.biz/WsHandler.ashx?userId=5
Disconnected null[object WebSocket]

And code:

function SYS_wsInit_begin():void
{
writeLog("ws init begin: " + ws_init_url);
trace(ws_init_url);
try
{
    websocket = new WebSocket(ws_init_url,"*");
    websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed);
    websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen);
    websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage);
    websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail);
    websocket.connect();
}
catch (err:Error)
{
    writeLog("ws init failed: " + err.message + err.name);
}
}

function handleWebSocketClosed(event:WebSocketEvent):void
{
    writeLog("Disconnected " + event.message + event.target);
    trace("Disconnected");
}

function handleWebSocketOpen(event:WebSocketEvent):void
{
    writeLog("Connected");
    trace("Connected");
}

function handleConnectionFail(event:WebSocketErrorEvent):void
{
    writeLog("Connection Failure: " + event.text);
    trace("Connection Failure: " + event.text);
}

crossdomain.xml:

<?xml version="1.0" encoding="utf-8" ?> 
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*"/>
    <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

I've also installed Socket Policy File Server with file:

<?xml version="1.0"?>
<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd">
  <site-control permitted-cross-domain-policies="*" />
  <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>

What can I do?


Solution

  • Oh, I've resolved the problem. After reading, http://forums.adobe.com/message/5297747 I've tried to check 843 port with fiddler, but I got only a redirection to index page.

    I checked my IIS configuration. There was a binding on 843 port. After the binding was deleted and socket policy file server restarted the Web-socket connection was established!