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

forwardDebugPort does not work correctly if more than one device / emulator #356

Open
cancan101 opened this issue Mar 29, 2016 · 8 comments

Comments

@cancan101
Copy link

cancan101 commented Mar 29, 2016

:realm:forwardDebugPort
error: more than one device/emulator
===========================================================================
WARNING: Failed to automatically forward port 8082.
In order to use Realm in Chrome debugging mode, port 8082 must be forwarded
from localhost to the device or emulator being used to run the application.
You may need to add the appropriate flags to the command that failed:
    adb forward tcp:8082 tcp:8082
===========================================================================
@appden
Copy link
Contributor

appden commented Mar 29, 2016

@cancan101 this is somewhat expected because when using Chrome debug mode, the JS that's running in Chrome needs to make HTTP requests to localhost:8082, which should forward to that port on the device/emulator running the app. So if multiple devices are connected, then you would need to manually tell adb forward which device to forward that port to. See the -d, -e, and -s options in adb -h. You can list them with adb devices -l.

@cancan101
Copy link
Author

Yes, I know the command on the CLI. Is there no way to get the correct value from the launch configs and set it here?

@appden
Copy link
Contributor

appden commented Mar 29, 2016

I'm not really sure if there is a way to do that here. If you have any ideas, I'd love to hear them!

It's definitely something we need to address though considering they changed react-native run-android to run on all connected devices (see this commit).

@cancan101
Copy link
Author

What exactly is this port forwarding for anyways? At first I thought it might be realm browser, but I don't think that is the case?

@alazier
Copy link
Contributor

alazier commented Mar 30, 2016

@cancan101 port forwarding is for chrome debug mode.

@cancan101
Copy link
Author

What is special about realm here that it needs to set up this forwarding?

@alazier
Copy link
Contributor

alazier commented Mar 31, 2016

Unlike other react-native modules Realm apis are synchronous and are built directly on top of the JS engine. We do this for good performance (we don't have to copy data for every call) and api simplicity. This is why you are able to access object properties using normal property getters/setters rather than using async callbacks which we thought would be cumbersome and awkward.

To make chrome debugging work with this design we had to build an rpc server that allows us to synchronously forward all api calls so they are run on the device/emulator. This rpc server is what requires port forwarding and is only used when debugging in chrome.

@alazier alazier added the T-Doc label Apr 12, 2016
@alazier
Copy link
Contributor

alazier commented Apr 12, 2016

We should mention this in the docs.

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

No branches or pull requests

5 participants