ios React Native - 连接没有连接处理程序错误的含义?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44081674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 09:08:38  来源:igfitidea点击:

React native - connection has no connection handler error meaning?

iosreact-nativeconnection

提问by guribe94

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

我创建了一个新的反应项目,当我从 xcode 在 iOS 上运行它时,控制台给了我这个:

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 handlerthese lines mean and how to I resolve the issue?

2017-05-19 23:25:51.299771-0400 test[21948:1121429] [] nw_connection_get_connected_socket_block_invoke 3 Connection has no connected handler这些行是什么意思以及如何解决问题?

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?

当我尝试在我的应用程序中使用 fetch 并发现它不起作用时,我第一次注意到这一点。我在控制台中发现了这些消息,后来发现这些消息发生在我所有的应用程序中,所以我认为这意味着这是我的配置问题?

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);

回答by Arunkumar

Try Below process

尝试以下过程

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

Xcode 菜单 -> 产品 -> 编辑方案...

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

环境变量 -> 添加 -> 名称:“OS_ACTIVITY_MODE”,值:“禁用”

Run your app again

再次运行你的应用

回答by Dev01

I figured out the solution:

我想出了解决方案:

To turn off Verbose for OS Activity Mode

为 OS 活动模式关闭 Verbose

  1. From the xcode menu, Project -> Scheme -> Edit Scheme.
  2. Then select Runon the left and then select Argumentstab on the right.
  3. In Environment Variablesadd the name OS_ACTIVITY_MODEand value as disable.
  1. 从 xcode 菜单中,项目 -> 方案 -> 编辑方案。
  2. 然后选择Run左侧,然后选择Arguments右侧的选项卡。
  3. Environment Variables添加名称OS_ACTIVITY_MODE和值disable

Or see picture below.

或者看下图。

enter image description here

在此处输入图片说明

Note: credit for image goes to Ramkrishna Sharma

注意:图片归功于Ramkrishna Sharma

回答by Eric Musgrave

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).

这个错误很可能来自内置于 react-native 以连接到 react-devtools 的 websocket。如果您在调试时没有运行 react-devtools,那么您将收到此错误,并且还会在桥上发送一堆消息,抱怨无法打开 websocket(如果您正在使用,您只会看到这些错误)类似于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

一旦您安装并打开 react-devtools,错误就会停止。请参阅这些说明以了解如何操作:https: //github.com/facebook/react-devtools/blob/master/packages/react-devtools/README.md

回答by Moritz

To disable the websocket streams I did the following:

要禁用 websocket 流,我执行了以下操作:

  • 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)

  • 在 xcode 中:Libraries/React.xcodeproj/React/Inspector/RCTInspectorPackagerConnection.m:在它之后找到- (void)connect {并添加return;

  • 在 node_modules/react-native/Libraries/Core/Devtools/setupDevtools.js 中:替换if (__DEV__)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.

这很丑陋,但比 OS_ACTIVITY 解决方案好很多,因为它不会隐藏或阻止任何其他调试工具。

回答by kontinuity

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:

就我而言,这是由于防火墙应用程序(Little Snitch)在从 react-native 应用程序运行时从不请求访问。对我有用的步骤:

  • 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
  • 在模拟器中打开Safari浏览器
  • 访问 google.com 或任何域
  • 确保它打开页面。它会要求访问等
  • 在模拟器中重启你的应用
  • 重新开始记录 react-native log-ios

That should help.

那应该有帮助。

回答by davidchuyaya

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 Producton the top bar
  3. Click Scheme, scroll down to Edit Scheme
  4. Select Runon the left bar, Infoon the top tab
  5. Change Build Configurationfrom Debugto Release
  1. 打开 Xcode
  2. 单击Product顶部栏
  3. 单击Scheme,向下滚动到Edit Scheme
  4. 选择Run左边栏上,Info上面标签
  5. 变化Build Configuration来自DebugRelease

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

现在该应用程序不仅不再有错误,而且启动速度更快。其他“修复”仅隐藏错误。