我正在使用 AS3WebSocket 模块来连接网络套接字。当我在本地启动闪存时它运行良好(闪存文件在全局设置中被标记为受信任)。
但是当我用 flash 打开服务器页面时,它不起作用。我没有错误消息,只是在日志中“断开连接”。
WinServer2012、IIS、ASP.NET MVC4
以下是日志:
ws init begin: ws://www.sample.biz/WsHandler.ashx?userId=5
Disconnected null[object WebSocket]
和代码:
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);
}
跨域.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>
我还安装了带有文件的套接字策略文件服务器:
<?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>
我能做些什么?