"__nw_connection_get_connected_socket_block_invoke Connection has no connected handler" in logs
jaggerwang opened this issue ยท 133 comments
Workaround
Edit by @hramos, maintainer:
Several solutions have been presented in this thread:
OS_ACTIVITY_MODE
- Open Xcode.
- Open Product menu.
- Select Edit Scheme...
- Add the following under Environment Variables:
Name:OS_ACTIVITY_MODE
Value:disable
- Run your app again
Using react-devtools
Alternatively, ensure react-devtools
is installed on your system.
Resolution
This is a known issue in the iOS Simulator. The issue will remain open to increase visibility. We are limited comments on this thread to core contributors. Pull requests with proposed fixes are welcome.
Original Issue
ENV
RN 0.32
iOS 10, iPhone 6 Plus
Problem
The console of Xcode continue print "__nw_connection_get_connected_socket_block_invoke 6 Connection has no connected handler".
Screen
+1
+1 not possible to fetch() remote json data on ios10 w/ RN 0.33
+1 ios 10.0.1 RN 0.33
+1
+1
+1
+1
Also happening with iOS 10.0.1 and RN 0.30
edit: I followed the recommendations here and am no longer getting the messages
Still an issue with:
RN 0.34
XCode 8.0
iOS 10.0 simulator
It's working with the iOS 9.2 simulator, however.
@marcpechaitis I'm not able to get to the library file for RCTWebSocket how did you find it? RTCWebSocket doesn't show up in my targets.
Thanks for responding @marcpechaitis . Ah. OK - I think the issue is that react-native is integrated into my project, which was originally ONLY a native obj-c project. React was integrated in afterwards (using instructions here). So my project doesn't have a Libraries folder that contains each of the individual xcodeproj files. The files are in the project, just not contained within a target:
+1
I was able to track down the RCTWebSocket.xcodeproj, open it, and alter the warning flags but the annoying __nw_connection_get_connected_socket_block_invoke
log persists. The method mentioned by @marcpechaitis (ref from here) to fix this does not work for pre-existing apps that have integrated react-native (vs apps that started as react-native apps). I can't even find where this log call is being fired off (not in obj-c files, not in any node-modules). still investigating.
edit: this is only an issue when building against main.jsbundle ... if I build against localhost (debug) these logs go away. I suspect that because I'm building in debug mode RN assumes I want to connect to the debug localhost server; which in this case is not true. My RN development is finished, and that portion of the app is running using the main.jsbundle file I created.
The build error that @marcpechaitis mentioned was fixed in RN 0.33
This error is a runtime error. Interestingly, it works for me in ios 10 simulator but not on the actual device.
@matthiasdilger oops, thought @marcpechaitis was referencing the OP.
Hi, guys! This works for me (on simulator):
- Xcode menu -> Product -> Edit Scheme...
- Environment Variables -> Add -> Name: "OS_ACTIVITY_MODE", Value:"disable"
- Run your app again, done! ๐
@HADB still fails on device for me
Got it working on device and simulator now by reassigning all signing certificates and entitlements in the project.
Xcode 8.0, ios10, iphone 5s
None of these solutions work for me at all. I've added in the exceptions in my info.plist and I just can't connect to my package server from my physical phone. I don't want to turn off errors like @HADB mentioned with OS_ACTIVITY_MODE as well, this is a legitimate error.
Any fix for this issue ?
+1
RN 0.34.0
iOS 10.0.1
iPhone 5S
In the iOS 10 simulator, I'm also getting a ton of __nw
related log messages.
+1
RN 0.35.0-rc.0
IOS 10.1
Iphone 7 Plus
+1
This seems to be an iOS 10 issue, and not a React Native one.
https://twitter.com/xenadu02/status/776669668404629504
Using OS_ACTIVITY_MODE=disable
(as HADB suggests) is the only current workaround.
@aleclarson I agreed with the log part but react-native still fail to fetch the bundle file on IOS 10
@frnk94 Are you talking about the .jsbundle
? The packager is serving my development bundle just fine.
You might be using an outdated AppDelegate.m
if it doesn't have this:
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
@alanchenup I think its an issue with my AppDelegate.m not connecting to my actual device thanks for the reply i'l fix my code ! :). It working great in simulator
i got it solved by xcode menu commands:
product -> clean
and (hold down option key)
product -> 'clean build folder'
+1
RN 0.34.0
iOS 10.0.1
iPhone 5S
working in iOS 10 simulator but not work in real iphone 5S
@pietgk No such luck with that solution for me.
OS_ACTIVITY_MODE=disable
works but it's more of a nuclear option given that it hides all your NSLog statements when running on a device. Perhaps it's better to just live with the log pollution for now when running on device.
@aleclarson @frnk94 Actually, the real error we get I think is :
Sending websocketFailed with no listeners registered.
I cannot reload js from server either, on the physical device that is.
+1
+1
@marcpechaitis Thanks for sharing my article!
+1
I get this when I have both remote debugging and console debugging (via react-native log-ios
). Disabling remote debugging solves the problem.
@warrenronsiek how to disable remote debugging?
@JansenLi If you don't know what it is, this probably isn't causing the problem. In your simulator hit command+D and a menu will pop up where you can enable or disable 'Debug JS Remotely'.
+1
+1
Got this error when my phone was not connected to Wifi.. ๐
The solution from HADB above worked for me, but it's missing a few steps in XCode8, which are added here for clarity:
- Xcode App -> Product -> Scheme -> Edit Scheme...
- Run -> Arguments -> Environment Variables -> Add (+) -> Name: "OS_ACTIVITY_MODE", Value:"disable" -> Close
- Run your app again, done! ๐
This does remove the errors while running, but I'm not sure if it solves the underlying problem.
+1
not helpful, trying to figure out what's going on
Still present on
RN 0.40.0
iOS 10.1
iPhone 6+
(Clean install with react-native init
)
Disabling the logs work, or I can just filter and ignore them, but does anyone know what/if something is actually broken from this?
+1
+1
+1
+1
iOS 10.2
RN 0.35
+1
iOS 10.2
RN 0.40
The message '__nw_connection_get_connected_socket_block_invoke' log message is occurring once a second in the 'react-native-router-flux' project I'm evaluating. The message appears to be from a compiled library because a simple text search didn't reveal anything from node_modules etc.
Please have a look at #10027 (comment) or http://stackoverflow.com/a/39461256/158525
Xcode 8 with iOS 10 displays much more low level debug statements.
+1 RN0.34 and RN0.32
still have the same issue with RN 0.40 and XCode 8.2.1
+1
+1
+1
iOS 10.2
RN 0.35
for me this issue is gone after upgrding to rn0.40
+1
Xcode 8.2.1
RN: 0.40
I have the same project on 2 Macs, stopped working on the one where I had to reinstall node/npm (and therefore all the global dependencies). It still works fine on the other one (however, could not get it working on a real iPhone). So to me it looks like something unrelated to Xcode/iOS.
Update: after cleaning node_modules and npm i, working fine, life's back to normal :)
Well, sort of :) still getting these every second, the app seems to be working though.
__nw_connection_get_connected_socket_block_invoke 60 Connection has no connected handler
And it's gone now. As unexpected and unexplained as it came.
Possibly unrelated, but this issue was solved for me once I turned off the Guided Access accessibility mode off on my iPhone 6. Seems far fetched, but still...
+1
no solutions thus far have helped
Edit Scheme -> Run -> Arguments - new env. var. OS_ACTIVITY_MODE
with disable
helped me
You can silence the error with OS_ACTIVITY_MODE, this is just spurious logging from the websocket we open to React Devtools.
Hi @javache
I would kindly disagree with your point of view.
Indeed many of us are aware that disabling OS logging will prevent this to show. But this also prevent us to do normal debugging of our apps... Just again last week our team had an issue and it took us for ever until we remember to reactivate the os logs to catch the error and sort our issue...
that is not an problem.
What's wrong with people closing this issue ? Disabling the error in output console is not a solution. What's causing the problem, what's going on ? Is this an error or a warning ? Why all these same outputs (with an increment) are showing indefinitely ? I think that's the only relevant point. Tell me if I'm wrong...
I am getting this error/warning when using fetch to my api on the net, bundle loads properly(ios10.3/RN 0.43-rc4). Server receives the request and sends the response but RN never receives the response.
So my real issue here is not receiving the response and not about the warnings.
Guys, please reopen this issue. Thanks.
Please look into it.
XCode 8.2.1
RN .43
iOS 10.3
Same thing here. Disabling the console to hide the issue isn't an option for me.
Disabling the console to hide the issue shouldn't be an option for anyone. Closing your eyes also stops you from seeing the warnings.
Disabling the output means I can't debug anything else. This should be reopened!!!
Please reopen the issue.
Sweeping the error under the carpet doesn't sound like a solution at all.
Commenting +1 is not helpful here, so please stop doing that. Per https://twitter.com/xenadu02/status/776669668404629504 this is a simulator issue, which should be resolved in a future update.
Fair comment @javache.
That being said I'm seeing this when running on the device in both debug & release mode. It's not the kind of issue that causes one to lose sleep at night, but it can def be considered noise pollution ;)
So if you recognize it as an problem that should be fixed in a future update, why not keep this issue open to reflect your position on this?
Not an XCode workaround, but this alleviated the pain for me when using the terminal.
react-native log-ios | grep -v __nw_connection_get_connected_socket_block_invoke
- This reproducible on real devices in dev mode.
- Also log messages from
libnetwork.dylib
itself is definitely Apple fail, I have to say that uncontrolled spam in console is personally RN behaviour. If I do not dumb things, I should not see console errors every 2 secs.
Note for RN devs:
Source of problem, is reconnection logic in RCTWebSocketObserver
(at least in RN 0.42.3) or in the [RCTDevMenu packagerURL]
. Method reconnect
spam OS with periodic retries. Most wonderful for me was the fact that it try to connect to 'http://localhost.8081/message' from real device.
@javache Just a heads up:
Per https://twitter.com/xenadu02/status/776669668404629504 this is a simulator issue, which should be resolved in a future update.
Also seeing this on a real device running 10.3.1 (14E304) with RN 0.44.0.
EDIT: Whoops, just saw @vovkasm already informed you, sorry! Was reading from the top but all the "+1"s got to me and I stopped reading.
Did someone say that typing ๐ works well?
This is happening on a real device. I could disable the messages, but it sounds like a thing that requires fixing / explaining.
@cmaitchison suggestion does the trick but in my case, the __ at the start are not needed
react-native log-ios | grep -v nw_connection_get_connected_socket_block_invoke
Does anyone foresee a real solution to this instead of just turning off logs? My OCD goes insane at this issue but also about turning off logging. Am I the only one?
@fgaleano your are not the only one. I have an idea, but have no time to implement it currently.
I think, that RN needs to implement some sort of configuration flag to optionally enable/disable connect to host machine. Probably this flag can be runtime switch in dev menu... but not sure.
Currently I use various workarounds to filter out unwanted messages from the console (grep or equivalents if log to terminal). I wouldn't recommend to disable logs with OS_ACTIVITY_MODE, because it hides other important messages :-/
I get that posting +1 isn't helpful. How is it helpful closing an open issue? Seems like Facebook has some strange kafkaesque policies on bugs
@vovkasm How do you filter out messages in xCode?
@andreyslyusar nohow, Xcode has not any filters in console :-(, also some advanced filters exists in Console application on Sierra.
But grep still most powerful way to do filtering to me, so I use iOS Console, it contains command line application inside bundle.
So I can do /Applications/iOS\ Console.app/Contents/Resources/iosconsole | egrep anything
from terminal.
Just some thoughts on this. Sure, setting the OS_ACTIVITY_MODE to disable, blocks the natively thrown errors from being thrown. That being said, if you are in the test-debug phase, seeing the constant slew of nw_connection_get_connected_socket_block_invoke messages can get in the way of seeing what we actually want to see in the console (checking outputs, app state, etc). As long as you keep in mind this fix is temporary, and can be of great aid. Ciao!
It still happens with RN 0.44.0, iOS 10, iPhone 5S.
Keep seeing "__nw_connection_get_connected_socket_block_invoke" every second is very annoying, so OS_ACTIVITY_MODE temporary fix is very helpful.
Seeing this too. Have been for a while. Been ignoring it for a while, but it's getting to me :).
RN 0.44, Xcode 8.3.3
To expand on the explanation from @javache, this error is 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
- neither @javache nor anyone from facebook did anything to explain the issue in this thread :-(
- react-devtools is good when it works :-) but most times you'll run into bugs (for ex. debugger simple not working in RN 0.45.1, why devtools will?)
- did your got react-devtools working when run application on real iOS device?
@vovkasm
Regarding your #3, I was able to get react-devtools working from a real iOS device, but the message in the xcode console still comes up. I think that is because of the way I solved it, as follows:
At the top of my entry point in JS, I added the following hook into react-devtools:
require('react-devtools-core').connectToDevTools({
host: '192.168.2.115',
port: '8097',
});
(obviously replace the IP with your own workstation IP address).
That creates the connection to react-devtools, but it seems like the internal react-native code is still trying its own connection, and so the message continues to show up in the xcode console.
I have not yet worked out how to conditionally use the require('react-devtools-core')
solution ONLY when using a physical device without manually (un)commenting out the code.
I will second that this was a react-devtools problem for me. Once I installed them, I had all messages immediately stop. Here are the installation instructions: https://github.com/facebook/react-devtools/blob/master/packages/react-devtools/README.md
It's indead react-devtools problem, as soon as I start it up, the annoying logs stops.
So it was react-devtools all along?? They should put that in HUGE BLACK LETTERS!