hamze issa
hamze issa

Reputation: 13

React Native socketio can' t connect to nodejs server (The server can be reached by browsers)

I'm using socketio to connect a react native app to a nodejs server on Azure. The server can be reached by browsers which makes me confident it's running and accessible, but my react native app can't connect to it. here's my code:


Client: (react native app inside the constructor)

socket = io('http://bahbishco.cloudapp.net/node', { jsonp: false, transports: ['websocket'] });

Server:

let express = require('express');
let app = express();
let server = require('http').Server(app);
let io = require('socket.io')(server);

server.listen(8000);

Any help would be great, thanks in advance.

Upvotes: 0

Views: 103

Answers (1)

hamze issa
hamze issa

Reputation: 13

So I found out the problem was with the Azure virtual machine. I learned that I need to create an "end point" with the port I want to reach. As well as provide it with a specific priority level. After doing so, the server worked fine. It's a naive mistake really but I'm still new with Azure, so I thought of posting the answer for anyone who might face the same issue

Upvotes: 1

Related Questions