2013-05-09 79 views
4

我正在使用AS3WebSocket模塊來連接Web套接字。當我在本地啓動閃存(在全局設置中將閃存文件標記爲可信)時,它工作正常。Flash WebSocket斷開

但是,當我用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); 
} 

的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> 

我我也是安裝帶有以下文件的套接字策略文件服務器:

<?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> 

我該怎麼辦?

回答

0

哦,我已經解決了這個問題。 看完之後,http://forums.adobe.com/message/5297747我試着用提琴手檢查843端口,但是我只有一個重定向到索引頁面。

我檢查了我的IIS配置。 843港口有約束力。在綁定被刪除並且套接字策略文件服務器重新啓動後,Web套接字連接就建立了!

+1

用於在unix終端或cygwin下檢查策略服務器:'echo -ne' \ 0'| nc -v example.com 843' – fsbmain 2013-05-17 10:28:35