16

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.

Philipp Kyeck
  • 18,402
  • 15
  • 86
  • 123
Juko
  • 293
  • 1
  • 3
  • 6
  • I've always just seen this error repeatedly in the Xcode log and assumed it had something to do with `react-native` and not my project. My fetch calls have no issues. – MattyK14 Feb 20 '18 at 19:19
  • 3
    Did you find a resolution to this? I am also struggling with the same situation and have lost a full day of work. – vizon Mar 14 '18 at 01:42

2 Answers2

1

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

0

Is your server HTTPS?

If yes, I'm not sure what the problem is either.

But if not, then you probably haven't added the domain of your server in your iOS app's configuration to enable insecure fetching.

You can add it via Xcode or in the './ios/YOUR_PROJECT_NAME/Info.plist' file.

Part of the info.plist file should look something like this after adding:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
        <key>192.0.2.1:3000</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>
river737
  • 89
  • 5