0

Я пытаюсь подключится к сокету с помощью socket.io-client но получаю в консоль только

SocketRocket: In debug mode. Allowing connection to any root cert 

Я проверил разные версии библиотеки и React-Native и ничего не получается. Думал, что адрес сервера не правильный но проверил и он работает как надо. Так же создал Node.js на localhost, обратился к нему и все работает а на удаленный сервер не конектится.

"socket.io-client": "2.0.4",
"react-native": "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")
    }
}

1 ответ 1

0
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);
    };

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.