Using the remote api (remote_api_shell.py) works fine on the production server. However, it only works on the development server when the development server is serving on localhost. It does not work when the server is running on specific IP (for example, dev_appserver.py --host=192.168.0.1).
This is using the Python SDK. I'm kinda sure this worked on version 1.7.5. It does not work on 1.7.6 or 1.8.0.
Here's a specific case:
Run the server and let it bind to the default address (localhost:8080):
/path/to/dev_appserver.py myapp/app.yaml
INFO     2013-05-25 19:11:15,071 sdk_update_checker.py:244] Checking for updates to the SDK.
INFO     2013-05-25 19:11:15,323 api_server.py:152] Starting API server at: http://localhost:39983
INFO     2013-05-25 19:11:15,403 dispatcher.py:98] Starting server "default" running at: http://localhost:8080
INFO     2013-05-25 19:11:15,405 admin_server.py:117] Starting admin server at: http://localhost:8000
Start the remote API shell, and it works fine:
$ ./remote_api_shell.py -s localhost:8080
Email: x@x
Password: 
App Engine remote_api shell
Python 2.7.2+ (default, Jul 20 2012, 22:15:08) 
[GCC 4.6.1]
The db, ndb, users, urlfetch, and memcache modules are imported.
dev~furloughfun> 
However, if you start the server with a specified host:
/path/to/dev_appserver.py --host=192.168.0.1 myapp/app.yaml
INFO     2013-05-25 19:11:53,304 sdk_update_checker.py:244] Checking for updates to the SDK.
INFO     2013-05-25 19:11:53,554 api_server.py:152] Starting API server at: http://localhost:44650
INFO     2013-05-25 19:11:53,633 dispatcher.py:98] Starting server "default" running at: http://192.168.0.1:8080
INFO     2013-05-25 19:11:53,634 admin_server.py:117] Starting admin server at: http://localhost:8000
Notice it says Starting API server at: http://localhost:44650 even though the content is served at http://192.168.0.1:8080. Is this indicative that you can only run the remote api on localhost? Perhaps for security reasons?
Also, when you try the remote_api_shell.py now, you can only log in with a valid account (no bogus accounts allowed) and it immediately errors and terminates.
The console errors end with:
urllib2.HTTPError: HTTP Error 200: OK
and the local development server outputs:
INFO 2013-05-25 19:24:06,674 server.py:528] "GET /_ah/remote_api?rtok=90927106532 HTTP/1.1" 401 57
Anyone know what's going on here?
Is it impossible to access the remote API other than on localhost?
Is it impossible to access the remote API (even on localhost) if your content is served on a specific IP?
It seems that api server doesn't have option to set host. dev_appserver.py has options to set host & port for content and admin server, and for api server only port (api_port option). Example:
dev_appserver.py --host=192.168.5.92 
                 --admin_host 192.168.5.92 --admin_port 9000 
                 --api_port 7000 .
Running this reports:
 api_server.py:153] Starting API server at: http://localhost:7000
 dispatcher.py:164] Starting server "default" running at: http://192.168.5.92:8080
 admin_server.py:117] Starting admin server at: http://192.168.5.92:9000
Looking into the source of GAE dev_appserver, caller of the method of api_server which starts the server is module devappserver2.py and the line is:
apis = api_server.APIServer('localhost', options.api_port,
                             configuration.app_id)
You can see hardcoded host name localhost.
If you find no good workaround, I would suggest to patch devappserver2.py by introducing a new option and report issue with patch attached?
Now, at least from version 1.9.27 of the SDK, the option --api_host helps with that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With