Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: bad runtime process port [''] on App Engine

I'm developing a site with GAE and webapp2. Occasionally while running my development server, I get the following error out of nowhere, with no stack trace:

http_runtime.py:404] bad runtime process port ['']

Sometimes this happens when I change part of my database schema (it's still early in development) and the problem is fixed if I restart the server and clear the datastore. However sometimes it happens for seemingly no reason.

The solution is always to just restart the server, but I feel weird not knowing why I'm getting this error. Is this something that just happens when the server has been up for too long? Is there anything I can do to prevent it? Does this happen in production? I want to know before I start thinking about deploying.

like image 702
user2571032 Avatar asked Oct 21 '22 01:10

user2571032


2 Answers

Though I'm not sure about the exact mechanism, from the log trace and looking at http_runtime.py, I believe that goapp and devappserver communicate over stdin and stdout, probably using a pipe like mechanism. http_runtime::start() parses args to acquire the port to be used to run the server. If any of the strings in args contain {port}, it replaces that substring with the selected port. This allows a user-specified runtime to pass the port along to the subprocess as a command-line argument.

Using fmt.PrintXXX() in init() seems to break this by modifying the contents of Stdout. This particular error is thrown at line 391, and is due to http_runtime getting a ValueError exception while trying to convert the port argument to an int.

Please check if you are using fmt.PrintXXX() in init. Please switch to writing to stderr, or better yet use the log interface. This is what worked for me.

You can check this google groups link(https://groups.google.com/forum/#!topic/google-appengine-go/v_6-qY0-dD8) for more details.

like image 133
79man Avatar answered Oct 24 '22 02:10

79man


For reference the error is coming from this line of code:

https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/tools/devappserver2/http_runtime.py

It is in the start() function so maybe something is causing your dev_app_server to restart itself and it is trying to reuse a port that is not available anymore?

Can you try to enable debugging with devappserver and see if you can reproduce it and paste in the context?

dev_appserver.py --dev_appserver_log_level=debug sets the log output to debug level.

From dev_appserver.py --help

like image 28
daodennis Avatar answered Oct 24 '22 03:10

daodennis