I am using the AS3WebSocket module to connect web sockets. It works well when I run flash locally (the flash file is marked as reliable in global settings).
But when I open the server page with flash, it does not work. I have no error messages, just βdisconnectβ in the log.
WinServer2012, IIS, ASP.NET MVC4
Here are the logs:
ws init begin: ws://www.sample.biz/WsHandler.ashx?userId=5 Disconnected null[object WebSocket]
And the 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 also installed the Socket Policy file server with the 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?
source share