41

I created a new react project and when I run it on iOS from xcode, the console gives me this:

2017-05-19 23:25:34.119 [info][tid:main][RCTBatchedBridge.m:77] Initializing <RCTBatchedBridge: 0x6100001a6c80> (parent: <RCTBridge: 0x6100000c46e0>, executor: RCTJSCExecutor)
2017-05-19 23:25:51.287 [info][tid:main][RCTRootView.m:295] Running application test ({
    initialProps =     {
    };
    rootTag = 1;
})
2017-05-19 23:25:51.289 [info][tid:com.facebook.react.JavaScript] Running application "test" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2017-05-19 23:25:51.299771-0400 test[21948:1121429] [] nw_connection_get_connected_socket_block_invoke 3 Connection has no connected handler
2017-05-19 23:25:53.335282-0400 test[21948:1121426] [] nw_connection_get_connected_socket_block_invoke 4 Connection has no connected handler
2017-05-19 23:25:55.349190-0400 test[21948:1120112] [] nw_connection_get_connected_socket_block_invoke 5 Connection has no connected handler

What do 2017-05-19 23:25:51.299771-0400 test[21948:1121429] [] nw_connection_get_connected_socket_block_invoke 3 Connection has no connected handler these lines mean and how to I resolve the issue?

I first noticed this when I tried to use fetch in my application and found it did not work. I found these messages in the console and later discovered these messages are happening with all my applications so I assume that means it is a config issue on my part?

I created a new test program to test what was causing this and found it happens on a brand new project. Below is my code is that generated the log output above:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';

export default class test extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('test', () => test);
guribe94
  • 1,551
  • 3
  • 15
  • 29

6 Answers6

47

Try Below process

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

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

Run your app again

Arunkumar
  • 1,705
  • 1
  • 17
  • 25
  • Thank you! That worked, would you mind explaining why that worked? – guribe94 May 21 '17 at 21:26
  • 56
    This is not a solution, this is hiding errors. A real fix has not been found yet: https://github.com/facebook/react-native/issues/10027 – Ulises Giacoman May 22 '17 at 12:16
  • 1
    Actually, I found that my iPhone app, which has been working fine for years, suddenly stopped being able to talk to my web services. Adding this Environment Variable, and rebuilding/deploying the app fixed the error.... So, for me, this did more than just hiding a few error messages. – Mike Gledhill Jun 28 '17 at 12:24
  • 2
    This will hide your NSLog's when using a real device. Change the 'disable' value to an empty string when testing on a real device. See https://stackoverflow.com/a/41828707/672989 – Tieme Jul 26 '17 at 08:35
  • 1
    I still got the error. Even though I started react-devtools – Mark Thien Jun 16 '18 at 15:24
  • Thanks for mentioning react-devtools @MarkThien I turned on remote JS debugging and could not figure out why my screen was blank and wouldn't load anything with debug messages showing connection failure. It was trying to connect to a debugger. Installing the standalone react-native debugger helped solve my problem https://github.com/facebook/react-devtools/tree/master/packages/react-devtools – Alex Wang Jul 19 '18 at 14:55
  • "the OS_ACTIVITY_MODE solution became useless with IOS 11, as it blocks all NSLog statements, not only system logs. In our case, no log anymore - which I had a hard time linking to this hack I put in place before!" ([source](https://github.com/facebook/react-native/issues/10027)) – eis Jul 30 '18 at 16:16
  • This is not a solution as Ulises says This just bypass the warning. – Samitha Nanayakkara Jan 15 '19 at 04:56
19

I figured out the solution:

To turn off Verbose for OS Activity Mode

  1. From the xcode menu, Project -> Scheme -> Edit Scheme.
  2. Then select Run on the left and then select Arguments tab on the right.
  3. In Environment Variables add the name OS_ACTIVITY_MODE and value as disable.

Or see picture below.

enter image description here

Note: credit for image goes to Ramkrishna Sharma

Dev01
  • 13,292
  • 19
  • 70
  • 124
10

This error is most likely from the websocket that is built into react-native to connect to the react-devtools. If you aren't running react-devtools while debugging, then you will get this error, and it also pumps a bunch of messages across the bridge complaining about not being able to open the websocket (you will only see those errors if you are using something like rn-snoopy).

The error will stop as soon as you install and open react-devtools. See these instructions for how to do it: https://github.com/facebook/react-devtools/blob/master/packages/react-devtools/README.md

  • I'm running React Native on an iPad. I can't see how to tell it to connect to the react-devtools on my dev machine - ideas? – GreenAsJade Jul 02 '17 at 07:50
  • 1
    So you're implying the react-devtools is somehow required for running react native? That's odd... – AlxVallejo Sep 03 '17 at 19:06
2

To disable the websocket streams I did the following:

  • in xcode: Libraries/React.xcodeproj/React/Inspector/RCTInspectorPackagerConnection.m: find - (void)connect { and add return; just after it.

  • in node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js: replace if (__DEV__) with if (false)

this is quite ugly but a lot better than the OS_ACTIVITY solution, as it does not hide or prevent any other debugging tools.

Moritz
  • 1,590
  • 13
  • 8
0

In my case it was due to a firewall application (Little Snitch) that never requests access when running from a react-native app. Steps that work for me:

  • Open Safari browser in the simulator
  • Visit google.com or any domain
  • Make sure it opens the page. It will ask for access, etc
  • Restart your app in simulator
  • Restart logging react-native log-ios

That should help.

Arif Amirani
  • 26,265
  • 3
  • 33
  • 30
-1

I had the same problem, and my app's startup was significantly delayed because of the issue. The actual fix for me is detailed here, but I'll rewrite it in case the link breaks:

  1. Open Xcode
  2. Click Product on the top bar
  3. Click Scheme, scroll down to Edit Scheme
  4. Select Run on the left bar, Info on the top tab
  5. Change Build Configuration from Debug to Release

Now the app not only no longer has the errors, it starts up much faster. The other "fixes" only hide the error.

davidchuyaya
  • 3,960
  • 2
  • 16
  • 26
  • This isn't helpful at all, you're just building for release every time just to avoid getting such error? makes no sense, and you can't debug anymore. Not a good answer. – msqar Jan 14 '20 at 15:13