Monday, 3 April 2017

React native + SSL socket: Error: xhr poll error

I'm using socket.io-client to connect socket from react native app with ssl socket server and get an error at connect-error event - [Error: xhr poll error].

Here is my code from react native (client side):

import io from 'socket.io-client';

import Config from '../../config';

var socketConfig = {
    secure: true
}

function connect() {
    this.socket = io(Config.notificationUrl, socketConfig);
    // this.socket.connect();

    this.socket.on('connect', () => console.log("Socket connected", self.socket.id));
    this.socket.on('connect_error', (err) => console.log("connect_error", err));
    this.socket.on('error', (err) => console.log("error", err));
}

I have tried to add transports: ['websocket', 'polling'] to socketConfig, but I also got other error [Error: websocket error]. Also tried to use import io from 'socket.io-client/dist/socket.io', but not different.

Note: I connect successful to socket server which use http protocol.

I'm using react native 0.40.0 and socket.io-client 1.7.3.



via Quan Vo

No comments:

Post a Comment