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

fix(android-livereload-localhost): #1776

Closed

Conversation

luisvt
Copy link

@luisvt luisvt commented Jul 19, 2019

  • Use request proxy handler when livereload and appUrl localhost:8100
  • Reconnect when connection has not been established

This will allow users run:

ionic capacitor run android -l

and let connect the app to localhost:8100 without the need to use --address=0.0.0.0

* Use request proxy handler when livereload and appUrl localhost:8100
* Reconnect when connection has not been established
@luisvt luisvt force-pushed the fix-android-livereload-localhost branch from 37c05f6 to a32fa60 Compare July 19, 2019 06:39
@jcesarmobile
Copy link
Member

Thanks, but this only works on simulators, on real devices it will try to proxy localhost:8100, and that will fail because "localhost" will be the device, but the server is in the computer.

I think Ionic CLI will be updated to use --address=0.0.0.0 by default for Capacitor, so you won't need it in the future.

@luisvt
Copy link
Author

luisvt commented Jul 23, 2019

yes, the objective is also to let the user add the port fordwarding in the chrome inspector

@luisvt
Copy link
Author

luisvt commented Jul 23, 2019

When I run livereload using --port=0.0.0.0 the geolocation plugin stop working

@jcesarmobile
Copy link
Member

Ah, didn't think about port forwarding.

@jcesarmobile jcesarmobile reopened this Jul 23, 2019
@@ -173,10 +173,11 @@ public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) {
return null;
}

if (isLocalFile(loadingUrl) || loadingUrl.toString().startsWith(bridge.getLocalUrl())) {
if (isLocalFile(loadingUrl) || !bridge.getAppUrl().contains("localhost:8100") && loadingUrl.toString().startsWith(bridge.getLocalUrl())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a good check, will stop working if the user changes the default port. It's probably better to just check Config.getString("server.url") == null


HttpURLConnection conn;
boolean isContentTypeNull;
do {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really confortable putting a while with Thread.sleep, might be useful for reconnection, but could cause problems if the networks is down.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a better way you could point me, I'll change it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I could throw an error after 10 attempts

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested the reconnection doesn't seem to work, so just remove that code for now and make the other requested change

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

Successfully merging this pull request may close these issues.

3 participants