[]socket与node服务端连不上?按照官方案例

//初始化引擎
Laya.init(600,400,Laya.WebGL);
this.byte = new Laya.Byte();
//这里我们采用小端
this.byte.endian = Laya.Byte.LITTLE_ENDIAN;
this.socket = new Laya.Socket();
//这里我们采用小端
this.socket.endian = Laya.Byte.LITTLE_ENDIAN;
//建立连接
this.socket.connectByUrl("ws://45.78.**.**:3000");
this.socket.on(Laya.Event.OPEN, this, openHandler);
this.socket.on(Laya.Event.MESSAGE, this, receiveHandler);
this.socket.on(Laya.Event.CLOSE, this, closeHandler);
this.socket.on(Laya.Event.ERROR, this, errorHandler);
function openHandler(event){
//正确建立连接;
console.log("链接");
}
function receiveHandler(msg){
///接收到数据触发函数
console.log("接受");
}
function closeHandler(e){
//关闭事件
console.log("关闭");
}
function errorHandler(e){
//连接出错
console.log("出错");
}
输出:出错-关闭
 
有哪里写的不对,node端是好的,用web客户端可以连上的
已邀请:

Aar0n

赞同来自:

有没有报错信息,就这两个输出吗?

寻寻觅觅

赞同来自:

兄弟,你解决了吗

要回复问题请先

商务合作
商务合作