2016-11-08 47 views
0

將xml套接字連接到node.js websocket。它首先顯示連接消息。當一條消息發送到服務器時,它的顯示套接字關閉錯誤。flash xml套接字可以連接到node.js websocket?

import flash.net.XMLSocket;

 var client_socket: XMLSocket = new XMLSocket(); 
      client_socket.connect("localhost",8080); 
      client_socket.addEventListener(DataEvent.DATA, on_serverData); 
      client_socket.addEventListener(Event.CONNECT, on_serverConnection); 
      client_socket.addEventListener(IOErrorEvent.IO_ERROR,IOerror); 
      client_socket.addEventListener(Event.CLOSE,socketclose); 
      client_socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,socketsecurityerror); 


function socketsecurityerror(event:SecurityErrorEvent) 
{ 
    trace("socketsecurityerror"); 
} 

function IOerror(event : IOErrorEvent):void 
{ 
    trace("IOerror"); 
} 

function socketclose(event : Event):void 
{ 
    trace("socketclose"); 
} 

function on_serverConnection(event:Event) 
{ 
      trace("connected"); 

      var o :Object= new Object(); 
      o.hello = "initial_start" ; 
      // client_socket.send(JSON.stringify(o)); 
} 

function on_serverData(event:DataEvent) 
{ 
    trace("errorrrrrrrrrr"+event.target.data); 
} 

這是什麼問題,因爲它僅在向websocket發送數據時顯示連接消息和socketclose錯誤。

下面的代碼是我的websocket服務器。

var WebSocketServer = require('ws').Server 
, wss = new WebSocketServer({ port: 8080 }); 

wss.on('connection', function connection(ws) 
{ 

      ws.on('message', function incoming(message) { 
      }); 

      ws.on('close', function() { 
      }); 

      ws.on('error', function() { 
      }); 
}); 

這是xmlsocket和websocket通信的問題嗎?

謝謝

+0

http://stackoverflow.com/questions/10542577/flash-player-doesnt-connect-to-socket-policy-file-server-給安全錯誤 這似乎是一個類似的問題。但無法找到如何解決我的問題。 – swaraj

回答

相關問題