Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

DevAppServer wrong host for /_ah/api/static/proxy.html #240

Open
CrandellWS opened this issue Mar 30, 2016 · 18 comments
Open

DevAppServer wrong host for /_ah/api/static/proxy.html #240

CrandellWS opened this issue Mar 30, 2016 · 18 comments

Comments

@CrandellWS
Copy link

see google/google-api-javascript-client#175

As suggested at: https://cloud.google.com/appengine/docs/java/tools/devserver#Command_Line_Arguments
https://cloud.google.com/tools/android-studio/app_engine/run_test_deploy

When attempting to run the sample running the DevAppServer using Android Studio on pc and accessing via external device, "Chrome://inspect" shows an error connection refused because the usl points to localhost and it should be pointed to the host ip not the client.

This error is only found when the host and client have different localhosts (ie they are different machines).

tried answer at http://stackoverflow.com/a/33316693/1815624 but to no avail, though setting the ip to 0.0.0.0 might help track this:
i71wdm
amlayl

If I set the ip to the machine's network ip instead of 0.0.0.0 I get different 404 errors than if it was set to localhost.

@CrandellWS
Copy link
Author

@loosebazooka can we get a release bump please?

@patflynn
Copy link
Contributor

@loosebazooka should we file this as a bug under Cloud Tools for AS?

On Wed, Mar 30, 2016 at 5:15 AM, William Crandell notifications@github.com
wrote:

@loosebazooka https://github.com/loosebazooka can we get a release bump
please?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#240 (comment)

@loosebazooka
Copy link
Contributor

we can file a bug to change the template to set it to 0.0.0.0 or at least add a comment there?

@loosebazooka
Copy link
Contributor

@CrandellWS while this is not really related to dev appserver override, you should be able to edit your build.gradle file and set the httpPort in the appengine closure there.

@CrandellWS
Copy link
Author

@loosebazooka setting the value to 0.0.0.0 is how I can find the problem but does not fix it.

Or am I misunderstanding?

@CrandellWS
Copy link
Author

When using 0.0.0.0 everything works when using a browser on the same machine, regaurdless of browsing to localhost or 10.0.0.10 (as example)

but using a different machine or device that CAN NOT access the devappserver using localhost in the browser address bar and can only access with ip 10.0.0.10. I end up with 404 errors trying to access localhost on the remote machine that is not running the appserver.

let me know if I can clarify or if you want me to make a demo.

I made a gist based on the tutorial in the discription:
see -> https://gist.github.com/CrandellWS/05e887ef3a815f2e257d54e4259ac61b

as there is no live app I changed
https://gist.github.com/CrandellWS/05e887ef3a815f2e257d54e4259ac61b#file-src_main_webapp_js_appsrc-js-L28 https to http...

the build config is :

// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.32'
    }
}

repositories {
    jcenter();
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.34'
  compile 'com.google.appengine:appengine-endpoints:1.9.34'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.34'
  compile 'javax.servlet:servlet-api:2.5'
}

appengine {
  downloadSdk = true
  appcfg {
    oauth2 = true
  }
  endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
  }
}

@CrandellWS
Copy link
Author

by the way the port does not change only the host and I was wrong it is not a 404 error rather a connection refused because there is not a server running on the external machine...

http://localhost:8081/_ah/api/static/proxy.html?jsh=...
Failed to load resource: net::ERR_CONNECTION_REFUSED

and I am actually using port 8081 for this....

@CrandellWS
Copy link
Author

@loosebazooka You see the error when you click the 'Say "Hello" >>' button but not before

@loosebazooka
Copy link
Contributor

I'm not sure I understand, are you trying to access localhost from another machine? That would only reference that machine on which you are trying to reach localhost. Setting address to 0.0.0.0 only makes the app server accessible from other machines. More info : http://stackoverflow.com/questions/7534967/is-there-any-way-to-access-gae-dev-app-server-in-the-local-network

10.0.0.10 appears to be the address of your computer running the appengine application? In which case it should make sense that that's the only way to access it.

The javascript code you're referencing is some special code to detect that you're running the server locally and disable https. Keep in mind that if you're deploying this to app engine (on the cloud), you will need it to be an https address.

So, I guess it makes sense that you can only access it by 10.0.0.10. If you use 10.0.0.10, what breaks?

@CrandellWS
Copy link
Author

the problem is the DevAppServer is sending a link for localhost from 10.0.0.10 that should be 10.0.0.10 and not localhost.

So:
http://localhost:8081/_ah/api/static/proxy.html?jsh=...
Failed to load resource: net::ERR_CONNECTION_REFUSED

Should be:
http://10.0.0.10:8081/_ah/api/static/proxy.html?jsh=...

but it is not, hence the problem is only apparent when accessing through a different machine/device/pc whatever...

@loosebazooka
Copy link
Contributor

oh interesting, can you set the httpAddress on the devAppServer to 10.0.0.10 and then launch? I wonder if it's something to do with the endpoints configuration.

@CrandellWS
Copy link
Author

same results

@CrandellWS
Copy link
Author

hence my assumption that
a68b880

might fix this issue

@loosebazooka
Copy link
Contributor

you seem to have your javascript loading stuff in two places :
https://gist.github.com/CrandellWS/05e887ef3a815f2e257d54e4259ac61b#file-src_main_webapp_index-html-L96

https://gist.github.com/CrandellWS/05e887ef3a815f2e257d54e4259ac61b#file-src_main_webapp_js_appsrc-js-L29

is everything updated correctly here?

On Wed, Mar 30, 2016 at 7:44 PM, William Crandell notifications@github.com
wrote:

hence my assumption that
a68b880
a68b880

might fix this issue


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#240 (comment)

@CrandellWS
Copy link
Author

yea I had separated the javascript...but for this I put it back and forgot to delete the js file...I updated the gist to clarify
https://gist.github.com/CrandellWS/05e887ef3a815f2e257d54e4259ac61b

@CrandellWS
Copy link
Author

You are correct that DEV_APPSERVER_DEFAULT_ADDRESS does not fix this, as I had hoped...

@loosebazooka if I can help further let me know, as in the future I will be wanting to test in this manner (using remote devices instead of emulators). Thank you for your time and help. I will check back into this at a later unknown date and time.

@loosebazooka
Copy link
Contributor

Everything I understand about the problem makes it seem like it should work. I'll set up a test and update the bug when I can.

@CrandellWS
Copy link
Author

@loosebazooka it would be nice to have another clearly reproduce this, thanks, the easiest way to reproduce this I know, would be to use "Android Studios" set up a project and add a "Google Cloud Module" after you add or import the new module, all you will need to do is adjust the build.config and run it.

    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.34'
    }

and

dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.34'
  compile 'com.google.appengine:appengine-endpoints:1.9.34'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.34'
  compile 'javax.servlet:servlet-api:2.5'
}

Readers please remember to also set the IP and port information as is described elsewhere in this thread.

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

No branches or pull requests

3 participants