简体   繁体   中英

IOException: unexpected response from remote api

I'm having exactly the same problem as this person:

https://groups.google.com/forum/#!topic/google-appengine-java/4y90M9NlWsA

but there are no responses and I can't see anything else on the internet that helps. Does anyone know why this would happen?

    RemoteApiOptions options = new RemoteApiOptions()
        .server("localhost", 8888)
        .credentials("blah@blah.blah", "");
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);

The stacktrace is:

Exception in thread "main" java.io.IOException: unexpected response from remote api: {rtok: null, app_id: MyCorrectAppId}

at com.google.appengine.tools.remoteapi.RemoteApiInstaller.getAppIdFromServer(RemoteApiInstaller.java:326)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.loginImpl(RemoteApiInstaller.java:278)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.login(RemoteApiInstaller.java:239)
at com.google.appengine.tools.remoteapi.RemoteApiInstaller.install(RemoteApiInstaller.java:106)
at uk.blah.blah.MyClass.main(MyClass.java:114)

I've noticed you've set the <application> element inside appengine-web.xml to MyCorrectAppId . That's the problem. As Eugene rightly pointed out, the ID must be all lowercase , like mycorrectappid . Quoting Dan Sanderson's book Programming Google App Engine :

Because the application ID is used in the domain name, an ID can contain only lowercase letters, numbers, or hyphens, and must be shorter than 32 characters. Additionally, Google reserves every Gmail username as an application ID that only the corresponding Gmail user can register.

If you are working in Eclipse, you need to remember that when setting up a new web application project (there is an option towards the bottom of the "New Web Application Project" dialogue that allows you to specify the ID instead of leaving it blank).

在此输入图像描述

For a standalone environment, I think you're probably fine if you leave the ID blank (it will default to "no_app_id").

Hope that helps!

According to the code of the RemoteApiInstaller.getAppIdFromServer method the exception unexpected response from remote api can be thrown when no app_id property found in the response body. And it seems that in your case it is probable that MyCorrectAppId does not match the PAIR_REGEXP pattern, ie it contains any characters other than digits, letters in lower case, tilde, underscore or minus sign.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM