Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native: Why do I get network errors when testing on iOS device

I am developing currently in React Native an app. After testing everything on the simulator I decided to run our app on a physical ios device.

When I try to connect to our API (fetch) I get following error (endless repeat everytime I try to connect):

nw_connection_get_connected_socket 12 Connection has no connected handler
2018-02-19 21:28:59.652134+0100 myApp[12063:4504022] TCP Conn 0x1c016b100 Failed : error 0:61 [61]

Strange thing: If I turn on Remote JS Debugging on my device it works without any problems. I think it works because it is using the connection of my laptop.

Any help would be appreciated.

like image 751
Juko Avatar asked Feb 19 '18 20:02

Juko


People also ask

How do I run a real iOS device in react native?

Open your react native app's directory, navigate to ios folder, and double-click on . xcworkspace file to open the Xcode. Next, open the Product menu, go to Destination, and select your device. If you don't have an Apple Developer account, you must create one to be able to run your project on an iOS device.

Can react native run on iOS?

Once you have your React Native project initialized, you can run npx react-native run-ios inside the newly created project directory. If everything is set up correctly, you should see your new app running in the iOS Simulator shortly.


1 Answers

8 Steps to Get Rid Of Error "nw_connection_get_connected_socket Connection has no connected handler TCP Conn Failed : error 0:61 [61]"

1-Xcode menu -> Product -> Edit Scheme...

2-Environment Variables -> Add -> Name: "OS_ACTIVITY_MODE", Value:"disable"

3-Xcode menu -> product -> clean

4-Xcode menu product -> 'clean build folder' (hold down option key)

5-Install react-devtools: npm install -g react-devtools

6-Run react-devtools: react-devtools

7-In your project, edit node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js by replacing 'localhost' with your development machine's IP address.

8-Build Project - (it will take long time for first time)

This steps for React Native nw_connection Errors, if the problem still occurs; follow the step on the image link (it will hide logs not solve)

image link -->this will hide logs and lets build (if build failing) not solves problem exactly

like image 194
Hüseyin Hür Avatar answered Sep 29 '22 23:09

Hüseyin Hür