Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to debug the app in Chrome, getting error : I Realm : Starting the debugging WebServer, Host: null Port: 8082 (adb logcat error) #465

Closed
vidyuthd opened this issue May 31, 2016 · 24 comments

Comments

@vidyuthd
Copy link

vidyuthd commented May 31, 2016

Hi I m unable to debug my app which has realm db, I see a white screen with nothing else, and also when I hit reload on the emulator, I m getting the following error while debugging in chrome console :

Running application "realm_mobile" with appParams: {"initialProps":{},"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF

POST http://localhost:8082/get_property:1 POST http://localhost:8082/get_property net::ERR_EMPTY_RESPONSE

POST http://localhost:8082/create_realm:1 POST http://localhost:8082/create_realm net::ERR_EMPTY_RESPONSE

Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://localhost:8082/create_realm.

When the debugger is removed, the code runs as its expected. I have checked the other issues raised with similar behaviour issue-276. I have tried manually port reverse & forward

adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082

I see the following error in adb logcat - I Realm : Starting the debugging WebServer, Host: null Port: 8082

I am using the following react(15.0.2), react-native(0.26.1), realm(0.13.0) versions. Is this supported ? Any help here from the logs attached and errors above would be appreciated.

Update : I have tried this on my android device also with same result. Without debugger, things work fine but once debugger is attached we get the white screen

Edit 1: Can you please look at this issue as it is blocking us badly. Thanks in advance.

@appden
Copy link
Contributor

appden commented Jun 6, 2016

@vidyuthd I apologized for taking awhile to respond. The Chrome debug mode works by the JS running in Chrome making synchronous HTTP calls to an embedded web server running in the app. It looks by net::ERR_EMPTY_RESPONSE that something is going wrong here. Do you see any errors in the adb logcat output after the line that you posted above?

@vidyuthd
Copy link
Author

Hi @appden , Nope I don't see any more errors in adb logcat other than this message : I Realm : Starting the debugging WebServer, Host: null Port: 8082 .

@appden
Copy link
Contributor

appden commented Jun 13, 2016

Are you using the stock emulator or Genymotion? I suspect there's a routing or firewall issue that's blocking Chrome from being able to make requests to the app running in the emulator. Will you try switching emulators to see if it works there? That would help us figure out the problem you're seeing. Thanks.

@alazier
Copy link
Contributor

alazier commented Jun 16, 2016

Any luck getting things working @vidyuthd ?

@vidyuthd
Copy link
Author

Hi @appden I am using stock emulator as well as device directly. I have tried with geny motion. What I have observed is with very less data(< 10 entries for each obj) things are fine, and debugging seems to happen fine across all emulators. But if we are dealing with a larger amount of data, lets say 1500 objs and processing on them in js.

The use case I wanted was to show result of join between two different entities, and for that I had to write the process in js after retreiving objs. I'm not sure if this maybe the cause but just giving you guys idea so that you can try out. So currently we are on sqlite, hence took time for me to test things.

@appden
Copy link
Contributor

appden commented Jun 29, 2016

I suspect you're seeing this issue because Chrome debug mode in the Android emulator is especially slow (see #491). If you just leave it alone, does it ever finally end up finishing processing all those objects?

@alazier
Copy link
Contributor

alazier commented Jul 21, 2016

Any luck here? Were you able to resolve this?

@octohedron
Copy link

I'm getting the same error:

I/Realm: Starting the debugging WebServer, Host: null Port: 8082

This is being dumped to the device's stderr

java.net.BindException: bind failed: EADDRINUSE (Address already in use)
    at libcore.io.IoBridge.bind(IoBridge.java:99)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:132)
    at java.net.ServerSocket.bind(ServerSocket.java:335)
    at java.net.ServerSocket.bind(ServerSocket.java:295)
    at fi.iki.elonen.NanoHTTPD$ServerRunnable.run(NanoHTTPD.java:1562)
    at java.lang.Thread.run(Thread.java:818)
Caused by: android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
    at libcore.io.Posix.bind(Native Method)
    at libcore.io.ForwardingOs.bind(ForwardingOs.java:56)
    at libcore.io.IoBridge.bind(IoBridge.java:97)

In the device I'm getting: Failed to execute 'send on 'XMLHttpRequest': Failed to load 'http://100.101.17.110:8082/create_session'. The IP belongs to google...

Digging a little more, with the Wifi on it's trying to get the wrong IP again, 192.168.1.5:8082, that is the device's IP address in my local network, it should be pointing to 192.168.1.4 which is the address of the development server, my machine

I think there might be some work to do in this file https://github.com/realm/realm-js/blob/v0.14.2-rc/react-native/android/src/main/java/io/realm/react/RealmReactModule.java

After trying many different things, including plugging/unplugging the device, ./adb reverse tcp:8082 tcp:8082, restarting the server, (all of this many times) it fixed itself automagically, but there has to be a way to avoid all this problems.

@alazier
Copy link
Contributor

alazier commented Jul 27, 2016

Unfortunately I think chrome debugging is completely broken on device for the time being and I think you are right that some work needs to be done to fix this. Hopefully in the meantime you can debug using an emulator or genymotion.

@mschipperheyn
Copy link

I have this on the IOS Simulator. Seemed to kind of "just started happening". Worked ok before. And now, I can't get past it.

I'm 0.14.3

screen shot 2016-09-05 at 12 56 47

@page-fault-in-nonpaged-area

Same. Exact problem on Android. Was working fine just a few days ago and BOOM. this shows up.

@page-fault-in-nonpaged-area

I tried adb forward/reverse 8081/8082, no luck. I also tried reversing to an older project snapshot, same problem. Have been getting this. Tried uninstalling via adb and reinstalling again, nothing worked.
screen shot 2016-09-06 at 3 22 34 pm

@page-fault-in-nonpaged-area

Is very frustrating because it also seems to interfere with fetch GET/POST. I can't tell for sure thou, since remote debugger doesn't work

@jaimecorrea
Copy link

Same issue, it just happened... it worked fine before... any news?

@ajonno
Copy link

ajonno commented Apr 20, 2017

im seeing this issue now too and really need to debug on device (for camera related features). is there a workaround or fix schedued as is a blocker for us at mom.?

@rbeers
Copy link

rbeers commented Apr 22, 2017

We are getting this error and also MUST be able to debug on device for bluetooth related feature.

@spittet
Copy link

spittet commented Aug 5, 2017

Hi everyone, I've managed to fix Chrome Debugging on Android and RN (react v16.0.0-alpha.12 and react-native v0.46).

I've been running in this issue and after reading a comment on a related issue I connected my laptop Wifi straight to my mobile device using it as a Mobile Hotspot. It's a bit annoying as I have to switch back to my wifi if I need to use the web (I don't want to run out of data) but at least I can see the state, actions, and console messages.

I tried on my iPhone but couldn't get it working.

@TGPSKI
Copy link

TGPSKI commented Sep 27, 2017

Greetings, I have a working implementation for Android.

Versions

  • OS: OSX 10.12.3 (16D32)
  • React Native: 0.48.4
  • Realm: 1.12.0 + Port update patch

Steps

  1. Add a postinstall script to your package.json:
... 
"postinstall": "bash ./scripts/patch_realm_port.sh",
...
  1. Add the project/scripts directory && touch patch_realm_port.sh

patch_realm_port.sh

#!/bin/bash

# android
perl -0777 -i -pe 's/(?mi-s)(private static final int DEFAULT_PORT = 8082;)/ private static final int DEFAULT_PORT = 8083;/g' "./node_modules/realm/android/src/main/java/io/realm/react/RealmReactModule.java"

# ios
perl -0777 -i -pe 's/(?mi-s)(#define WEB_SERVER_PORT 8082)/#define WEB_SERVER_PORT 8083/g' "./node_modules/realm/android/src/main/java/io/realm/react/RealmReactModule.java"
  1. Run yarn install on your root dir

  2. Build android release

  3. IMPORTANT: run the following adb commands

  • adb reverse tcp:8081 tcp:8081
  • adb forward tcp:8082 tcp:8082
  • adb forward tcp:8083 tcp:8083
  1. Start node server

  2. Launch android debugger & run

@chetmurphy
Copy link

Thanks @TGPSKI. Your steps worked for me on Windows 10 for android. I changed

DEFAULT_PORT to 8083 in RealmReactModule.java
WEB_SERVER_PORT to 8083 in RealmReact.mm

Then I used adb to set up the ports:
adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082
adb forward tcp:8083 tcp:8083

followed by

gradlew clean (to do a clean build) and
react-native run-android

My environment is

"react": "16.0.0",
"react-native": "^0.49.0",
"realm": "^1.12.0",

@arshbot
Copy link

arshbot commented Jan 6, 2018

@TGPSKI

Is the install script for iOS sound?

I see this location

"./node_modules/realm/android/src/main/java/io/realm/react/RealmReactModule.java"

Should it be pointing to this file?

Also, what is the solution if you don't rely on Android Studio at all? abd is an Android related command

@profiVideos
Copy link

On Windows 8.1, the above changes, settings and configurations did not work. I have since had to resign myself to not being able to use the Chrome Debugger with react native. On a different thread, I read an excellent description about why Realm & the Chrome debugger do not co-exist nicely. The best proposed solution was a "proper" debugger for react-native that did not rely on the javascript capabilities of Chrome. That made a lot of sense to me. I for one, really LOVE what Realm gives me and I'd rather have those features!

@lattice0
Copy link

Could somebody explain to me which things are running and where? I'm running an unconventional setup and need to know which port to redirect

@lattice0
Copy link

lattice0 commented Apr 3, 2018

Well, I was able to do some proper network redirection for my unconventional setup. For those who need it: #1732 (comment)

@Komeyl94
Copy link

For me running the following commands fixed it, thanks to @TGPSKI's suggestion:

  • adb reverse tcp:8081 tcp:8081
  • adb forward tcp:8082 tcp:8082
  • adb forward tcp:8083 tcp:8083

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests