我尝试使用socket.io-client连接到插座,但我只得到" socketocket:在调试模式下。允许连接到任何根证书"。我检查了图书馆的不同版本和反应,什么也没发生。我认为服务器的地址不正确,但已被检查,并且可以按应有的作用。我还在Localhost上创建了Node JS,连接到它,所有内容都可以使用,但没有连接到远程服务器。" socket.io-client":" 2.0.4","反应本":" 0.58.3"。
import SocketIOClient from 'socket.io-client'
componentDidMount(){
this.socket = SocketIOClient('wss://bitshares.openledger.info/ws',{
'force new connection': true,
reconnection: true,
reconnectionDelay: 10000,
reconnectionDelayMax: 60000,
reconnectionAttempts: 'Infinity',
timeout: 10000,
transports: ['websocket']
});
this.socket.connect();
// this.socket.send('123');
this.socket.on('connect', () => {
console.log("CONNECTED")
});
this.socket.onopen=function(){
console.log("onopen")
}
}
var ws = new websocket('wss://bitshares.openledger.info/ws');
ws.onopen = () => {
console.log("onopen");
// connection opened
};
ws.onmessage = (e) => {
// a message was received
console.log("onmessage",e.data);
};
ws.onerror = (e) => {
// an error occurred
console.log(e.message);
};
ws.onclose = (e) => {
// connection closed
console.log(e.code, e.reason);
};