Is it possible to use Websockets/Socket.IO with cellular data/4g?

534 Views Asked by At

I am making React Native App which requires constant connection between the clients and server. The app works only when using wifi. Has anyone managed to get this sort of thing working with Socket.IO? Or any other alternatives such that it works with cellular data? Why exactly does this work with wifi but not with cellular data?

Here is my code for connecting to the server running on my PC on port 3000:

const io = require('socket.io-client');
const socket = io('...'); // http://ip:3000
export default socket;

I would really appreciate it if someone could help me with this.

1

There are 1 best solutions below

0
Ben F On

Managed to get this working by hosting my server and Postgres database using Heroku and then connecting to it. Wasn't working because I was trying to connect to a private IP address (192.168.1.254) which only works when connected to the same Wifi.