Network connection problem in react native - javascript

I am trying to run react native app on android using expo cli. But getting this network connection error.network connection problem
Image is available on the above link.

in expo, if you are in development mode, both mobile and computer should be connected to the same wifi. so it can connect to your localhost.

Related

Communication between electron desktop app and react native app (client) using the same WiFi network

My react native app is responsible for sending information to my electron app, Is it possible to communicate an electron app with react native that is connected on the same WiFi network? If yes, how?
Im trying to find some articles, but I don't find anything helpful as of now.

react native can't connect to android device

I'm just start learning react native and I'm trying to use expo,
after I created my app using expo and try to connect it to expo app on android device
I got this error
Uncaught Error:java.net.socketTimeoutException: failed to connect to /172.28.118.45 (port 19000) from /192.168.1.3 (port 38238) after 10000ms
I'm using wsl2 on windows and I think the problem could be, there's no bridge between wsl2 ip and windows ip but I couldn't find solution for this issue
This happend me before, but using only react native in WSL (not with expo) and you're right, the WSL cannot reach your android device.
I find some solutions but none of this work for me, you can try it maybe with expo is different.
Check https://localcoder.org/running-react-native-in-wsl-with-the-emulator-running-directly-in-windows

expo react-native - disable timeout to metro in tunnel connection

My development environment is in ubuntu on wsl2 with vscode as editor running on windows using the remote wsl extension. I am running it on a physical android device using the Expo Go app using the tunnel connection on the same wifi network.
Everything works fine from scanning the QR Code to editing the code and it auto refreshes everytime I make changes on vscode. The problem is when I became idle(not making changes) for a short time, the connection somehow times out giving the error:
Cannot connect to Metro.
Cannot connect to Metro screenshot
What should be done here? How to disable the timeout if there's a way?

Send get request to local api from react native mobile project

I am developing a mobile app using react native, SQL Server and NodeJS.
I got an API in my localhost. I run my application on an emulator and try to get request from API. But I got this message in catch(error):
[Error:Network Error].
Can somebody help me please.
Actually you are unable to access the local development server because port hasn't been forwarded by ADB yet. Try to replace the "localhost" with your machine IPv4 address and check else you can also try map your local server port just like React Native does.
To forward a port using ADB run the following command in your terminal
adb reverse tcp:8163 tcp:8163 remember this only works if you are using Android 6.0+.

Why can't I get my android emulator to connect to my local server?

I am developing an app using React Native and made my server with node.js. For websocket connections I use socket.io
The thing is if I install the app to my android device and my android emulator, only my android device can connect to my local server. They both run the same code. I checked and the emulator has an active internet connection. Weird thing is I have an other app inside the emulator that connects to the same server without any problems using the same connection methods.
Do you guys have any idea why there is a problem like this?
Android emulators have a built in IP to use when connecting to something on your local machine.
If the socket is running on localhost, you want to connect to using the IP address 10.0.2.2 in the emulator.

Categories