Behrooz Erfanian
Behrooz Erfanian

Reputation: 21

React native with socket.io socket creates but it always on reconnect

I'm using "react-native": "0.60.4" and "socket.io-client": "2.1.1". I create socket connect as below, socket creates but it always on reconnect.

When I use

XMLHttpRequest = GLOBAL.originalXMLHttpRequest ?
    GLOBAL.originalXMLHttpRequest :
    GLOBAL.XMLHttpRequest;

in my project, it connects, but nothing works.

This is the socket code

let socket = io('http://192.168.0.6:8090', {
    transport: ['websocket'],
    jsonp: false 
});

console.log(socket);

socket.on('reconnecting', (attemptNumber) => {
    console.log(attemptNumber + " reconnecting... ")
});

Upvotes: 0

Views: 595

Answers (1)

Behrooz Erfanian
Behrooz Erfanian

Reputation: 21

Well, finally after 3 days struggling with this, I found the bug, looks like in react native is "transports" not "transport"

Upvotes: 2

Related Questions