react-native-debugger icon indicating copy to clipboard operation
react-native-debugger copied to clipboard

iOS: Simulator socket connection times out due to debugger

Open peggyrayzis opened this issue 8 years ago • 21 comments

Hi there! Thanks for the debugger, I use it daily and find it very helpful. 😀

After I rebuild in Xcode and launch the simulator, the socket connection to the debugger times out roughly 5 seconds after starting the app and the simulator crashes. Once I reload the simulator using command + R, I no longer have socket connection issues until the next time I rebuild.

Here's a screenshot of the crash screen on the simulator: glass

Here are some excerpts from my Xcode log that may be helpful:

2016-12-09 16:10:56.114498 bulbasaur[21709:8268397] [] __tcp_connection_start_block_invoke 53 sending event TCP_CONNECTION_EVENT_TLS_HANDSHAKE_COMPLETE in response to state ready and error (null)
2016-12-09 16:10:56.114739 bulbasaur[21709:8268397] [] tcp_connection_event_notify 53 event: TCP_CONNECTION_EVENT_TLS_HANDSHAKE_COMPLETE, reason: nw_connection event, should deliver: true
2016-12-09 16:10:56.115090 bulbasaur[21709:8268397] [] tcp_connection_get_statistics DNS: 3ms/4ms since start, TCP: 16ms/277ms since start, TLS: 11ms/287ms since start
2016-12-09 16:11:24.680962 bulbasaur[21709:8256238] [] tcp_connection_cancel 50
2016-12-09 16:11:24.681405 bulbasaur[21709:8268396] [] nw_socket_handle_socket_event Event mask: 0x4
2016-12-09 16:11:24.681745 bulbasaur[21709:8256238] [] tcp_connection_cancel 51
2016-12-09 16:11:24.682188 bulbasaur[21709:8268396] [] nw_socket_handle_socket_event Socket received WRITE_CLOSE event
2016-12-09 16:11:24.683606 bulbasaur[21709:8268396] [] __nw_socket_service_writes_block_invoke sendmsg(fd 20, 31 bytes): socket has been closed
2016-12-09 16:11:24.683948 bulbasaur[21709:8268396] [] nw_endpoint_flow_protocol_error [50.2 *IP address* cancelled socket-flow (null)] Socket protocol sent error: [32] Broken pipe

cc @kkemple

peggyrayzis avatar Dec 09 '16 21:12 peggyrayzis

Thanks!

But it seems related to packager, not debugger. If you are use the official http://localhost:8081/debugger-ui, the problem will not be reproduced?

Also, I can't reproduce the problem with same environment.

jhen0409 avatar Dec 11 '16 15:12 jhen0409

I get this error anytime I debug via react-native-debugger. The code works when debugging via chrome. My iOS (9.3 via Xcode 7.3) simulator freezes.

Assertion failed: (dispatch_get_specific((__bridge void *)self) == (__bridge void *)_workQueue), function -[RCTSRWebSocket assertOnWorkQueue], file /Users/dwaynecole/Clients/jitterClient_master/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m, line 353.

smooJitter avatar Dec 21 '16 06:12 smooJitter

@smooJitter would be great if you can provide your React Native version, I'll try to reproduce.

Also, I have https://github.com/facebook/react-native/issues/10927 for React Native ^0.37 (with Chrome debugger), I recommend use iOS 10.x simulator.

jhen0409 avatar Dec 21 '16 08:12 jhen0409

But it seems related to packager, not debugger. If you are use the official http://localhost:8081/debugger-ui, the problem will not be reproduced?

I don't get the same error using the Chrome debugger. I'm using an iOS 10 simulator in Xcode 8 running RN 0.35. Please let me know if there's anything else I can do to help you debug!

peggyrayzis avatar Dec 22 '16 16:12 peggyrayzis

@peggyrayzis I recently tried with Chrome debugger, I can get the same error, just click Product -> Clean in Xcode then start rebuild, but it doesn't appear in the next rebuild, It seems the same with this issue, could you try again?

jhen0409 avatar Jan 20 '17 09:01 jhen0409

I can also regularly reproduce this issue. it is quite difficult to work with.

georgewwindsor avatar Aug 17 '17 21:08 georgewwindsor

I'm struggling with this issue too. I don't know how to recover from it, or avoid it. Let me know if I can help solve it in any way.

jfhector avatar Aug 24 '17 22:08 jfhector

Actually the error isn't directly related to debugger, just client <-> debugger-proxy, we can tracking the webSocketProxy of RN packager, and RCTWebSocketExecutor of iOS. It's hard to me because I no longer cannot reproduce the problem.

Let me know the RN version might be helpful. :)

jhen0409 avatar Aug 25 '17 07:08 jhen0409

happens a lot for me. I am using expo version 20 with react-native 0.47.1.

Android device is not affected, only ios simulator.

Consumes a lot of time and is super annoying. Please also let me know if I can help somehow.

macrozone avatar Sep 05 '17 11:09 macrozone

I resolved this by setting my router IP to static at 192.168.0.10. For some reason this worked for me better than dynamic IP. I suspect this issue is router specific. 

Additionally, make sure your IP address is changed in the xcode stuff, dont leave it as 192.168.0.1. search for "localhost" as well, find the spots that have the wrong IP

  From: Marco Wettstein <[email protected]>

To: jhen0409/react-native-debugger [email protected] Cc: georgewwindsor [email protected]; Comment [email protected] Sent: Tuesday, September 5, 2017 4:17 AM Subject: Re: [jhen0409/react-native-debugger] iOS: Simulator socket connection times out due to debugger (#32)

happens a lot for me. I am using expo version 20 with react-native 0.47.1.Android device is not affected, only ios simulator.Consumes a lot of time and is super annoying. Please also let me know if I can help somehow.— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

georgewwindsor avatar Sep 05 '17 15:09 georgewwindsor

For what it's worth, I'm still seeing this after #133 was merged (running in production mode, using create-react-native-app and using the iOS 10.3 simulator).

Connection to http://localhost:19001/debugger-proxy?role=client timed out. Are you running node proxy? If you are running on the device, check if you have the right IP address in `ABI20_0_0RCTWebSocketExecutor.m`.

ABI20_0_0RCTFatal
-[ABI20_0_0RCTWebSocketExecutor setUp]
-[ABI20_0_0RCTBatchedBridge setUpExecutor]
__34-[ABI20_0_0RCTBatchedBridge start]_block_invoke_2.62
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread3
_pthread_wqthread
start_wqthread

carsondarling avatar Sep 07 '17 19:09 carsondarling

@jhen0409 I think this error can be reliably reproduced using an unmodified create-react-native-app and Version 10.0 SimulatorApp-829.6.

I've only been able to trigger this error when hot reloading is enabled.

screenshot 2017-09-22 12 45 16 screenshot 2017-09-22 12 45 36

Viral-Inc avatar Sep 22 '17 18:09 Viral-Inc

@Viral-Inc Thanks! Now I can reproduce the error by enable Hot Reloading in Expo project, but it actually got the same issue by using official debugger-ui page, and I can't reproduce on regular RN project by the same way, so I think it may have some problem in Expo client.

jhen0409 avatar Sep 23 '17 10:09 jhen0409

I helped to open issue https://github.com/expo/expo/issues/722.

jhen0409 avatar Oct 04 '17 13:10 jhen0409

I have the same issue on a real device and can't figure out how to fix that. Any updates?

Andrfas avatar Oct 09 '17 13:10 Andrfas

I have been experiencing it for months. I have tried using different phones, different machines. Its definitely not my environment.

*happens only after i "reload".

  • i do not have hot reloading enabled.

georgewwindsor avatar Oct 09 '17 18:10 georgewwindsor

@jhen0409 we really appreciate your help and hard work on this issue, and if there is anything we can do from our side to help you reproduce this issue, please let us know.

georgewwindsor avatar Oct 09 '17 18:10 georgewwindsor

...I fixed this issue by then use command npm start and shake to open developer menu, click ‘debug JS remotely’

My package.json here for reference: "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "postinstall": "rndebugger-open" },

"dependencies": { "react": "15.4.2", "react-native": "0.40.0", "react-redux": "^5.0.2", "redux": "^3.6.0" },

"devDependencies": { "react-native-debugger-open": "^0.3.15", },

yummyelin avatar Oct 18 '17 17:10 yummyelin

I think this happens when you have remote debugging enabled and when you save codebreaking kind of error. So when you save buggy code, bundle tries to load updated code but it could not, so times out hence this error

this should be handled in a better way though

karna41317 avatar Dec 04 '17 00:12 karna41317

Encountering this same issue...I have Expo running and when I run react-devtools in my terminal it doesn't connect. Can you have both of them running at the same time?

msnowai avatar Jan 16 '18 03:01 msnowai

I have other questions : I have connected the Android device but always timed out os:Windows react-native: 0.70.6 react-native-debugger: 0.13.0

image

YcodeMan avatar Dec 01 '22 10:12 YcodeMan