GAE: Why there is a constant POST request to /RPC2 - google-app-engine

I'm new to Google app engine not new to Python, there is a very confusing problem to me.
First of all, show you my version.
The problem is when I run the development server, there is a constant POST request to /PRC2, I have no idea where it came from.
See the screenshot below.
My main.py
from google.appengine.ext import webapp
import os
from handlers import MainHandler
CURRENT_VERSION_ID = os.environ.get('CURRENT_VERSION_ID', None)
if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
DEVELOPMENT = False
else:
DEVELOPMENT = True
config = {
'DEBUG': DEVELOPMENT
}
routes = [
(r'/', MainHandler), # Homepage
]
app = webapp.WSGIApplication(
routes, debug=DEVELOPMENT, config=config
)
And app.yaml
application: xxxxxxxxxxxx
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
static_dir: static
- url: /.*
script: main.app
libraries:
- name: webapp2
version: "2.5.1"
- name: jinja2
version: "2.6"

Strange. Try another port and look if you keep this strange POST. Or serve the post in your app and look what is in the request, to find out where it comes from.

You're probably launching dev_appserver on some port where an XML-RPC application is looking for a particular API.

Related

Endpoints: /_ah/api/ returns 404 after update

Problem fixed via Google Cloud support:
I removed the /_ah/spi/* handler from my endpoints yaml file, and the
- url: /.*
script: api.app
did not instantiate the endpoint.
It used to work before since the API was deployed for the previous version, but with the new version, there was nothing explicit to deploy the endopoints. So handlers need to be
handlers:
- url: /_ah/spi/.*
script: api.app
- url: /.*
script: api.app
Keeping the issue below for reference purposes
I've just deployed a new version of my application, and calls to http://app.appspot.com/_ah/api/app/version/method now return a 404. It worked perfectly before the update.
However, there's no trace at all in the logs, and no instance launched when I call/ping those URIs.
While if I call /_ah/whatever/app/version/method, I still have a 404, but it appears in my module logs, and it has the following message
{"state": "APPLICATION_ERROR", "error_message": "Not Found"}
The app is configured using modules, my app.yaml is defined with
application: appname
version: 2015-04-07
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /_ah/spi/.*
script: api.api.app
- url: /.*
script: www.www.app
secure: always
libraries:
- name: pycrypto
version: latest
- name: endpoints
version: 1.0
- name: webapp2
version: latest
- name: jinja2
version: latest
And, in api/api.yaml
application: appname
module: default
version: 2015-04-07
runtime: python27
api_version: 1
threadsafe: true
inbound_services:
- warmup
handlers:
- url: /.*
script: api.app
libraries:
- name: pycrypto
version: latest
- name: endpoints
version: 1.0
- name: ssl
version: latest
I've updated the app to serve this new version in the admin console, and all other modules work perfectly.
Also, I can't see my API in the API explorer, https://appname.appspot.com/_ah/api/explorer returns an empty list (while I see it when running the dev server on localhost).
Update: I've just noticed, looking at #bossylobster reply in GAE cloud endpoints - Api not updating after deploy, that I do not have "Successfully updated API configuration" in my logs after the "Completed update of a new alternate version". However, I have "API deletion serving" at about the time everything started to be 404. Yet, I have no idea why there's this API deletion query in my logs. Any idea of what can be wrong?
That's an app in production and so the mobile version is down at the moment. I'm happy to send the app ID to a devrel in PM if that helps.

App Engine Python Modules and inbound mail service

I am using App Engine Modules in my python project. (https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads)
I am also receiving email in m project:
https://developers.google.com/appengine/docs/python/mail/receivingmail
I want to direct the emails to my worker module and not the default module. To that end my worker.yaml has the following settings
worker.yaml
api_version: 1
application: integrate
module: worker
version: 1-0-0
runtime: python27
threadsafe: true
inbound_services:
- mail
builtins:
- deferred: on
handlers:
- url: /admin/.+
script: src.worker.main.app
login: admin
- url: /_ah/mail/.+
script: src.worker.main.app
login: admin
- url: /.*
script: src.worker.main.app
app.yaml
api_version: 1
application: integrate
version: 1-0-0
runtime: python27
threadsafe: true
builtins:
- deferred: on
handlers:
- url: /admin/.+
script: src.default.main.app
login: admin
- url: /.*
script: src.default.main.app
I even tried adding a dispatch.yaml
application: integrate
dispatch:
- url: "*/_ah/mail/.+"
module: worker
But no matter what I do the emails which reach my app are handled by the default module. Any idea what I am missing here? I see the emails coming in but no matter what I do they only go to the default module.
Inbound services could be used only within default module and that is expected behavior. The fact that it works for you locally in devserver is a bug, actually.
Just some additional info for the answer which may help folks in a similar situation.
I noticed in the DevServer log:
"Skipping dispatch.yaml rules because /_ah/mail/[EMAIL_ADDRESS_FOR_APP] is not a dispatchable path."
This is no doubt due to local config, however.
Regardless, the workaround I have now using Tasks is:
Dispatch or directly handle Inbound Mail in the default module
Provide a script handler that creates a Task, taking the relevant MailMessage data as the payload
Set the TaskQueue in queue.yaml to target the module you wish to process the payload data, e.g. a 'worker' module

GAE tutorial - browsing 'Localhost:8080' gives me server error?

I am using the Google App Engine GUI. Not sure what I'm doing wrong since I'm following Google's lead on this one. In the GUI, the app is running on admin port 8000 and listening in on port 8080. When I go to localhost:8080, I get a 'Server Error' in Chrome. Is this a firewall problem or a GAE problem?
helloudacity.py
import webapp2
class mainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, Udacity!')
application = webapp2.WSGIApplication([
('/', MainPage),
], debug=true)
app.yaml
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloudacity.application
You forgot to capitalize mainPage in your routes and debug=true to True. If you look at error console most of the errors should be there.
Try changing debug=true to debug=True.
The booleans on Python are True or False.
Google´s sample is right.

GAE dev_appserver "No module named lxml"

It seems lxml is not available for me in dev_appserver. I have test project is import lxml line built with windows python sdk 1.6.6. "No module named lxml". I assume something with installed version of python, but I have Python 2.7.
import webapp2
import lxml
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('Hello world!')
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
===
application: teslxml
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1"
- name: lxml
version: latest
==
dev_appserver.py teslxml
Update: This isn't true anymore, lxml is now shipped out of the box.
https://cloud.google.com/appengine/docs/standard/python/tools/built-in-libraries-27
lxml doesn't come out of the box with Google App Engine, you need to install it.
I kept getting the 'no module named lxml' error, but was unable to install the module separately and I resolved this by telling pip to install with a specific version number, like so;
pip install lxml==[versionnumber]

Error Python 2.7 on Google App Engine - Threadsafe cannot be enabled with CGI handler

I have tried to move to Python 2.7 from Python 2.5 but I keep getting the same error everytime.
I have made a very simple test in Python 2.5 working with the app.yaml file and just one script main.py and it works fine. The script it just a Hello World type to check everythin works fine.
app.yaml
application: sparepartsfinder
version: 1
runtime: python
api_version: 1
handlers:
- url: /blog
script: main.py
- url: /blog/new_entry
script: main.py
main.py
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
class MainPage(webapp.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, webapp World!')
application = webapp.WSGIApplication(
[('/', MainPage),
('/blog', MainPage),
('/blog/new_entry',MainPage),
('/blog/archive/.*',MainPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
When I change to Python 2.7 I follow the documents on the Google App Engine to the letter making the changes in both the app.yaml and main.py script.
app.yaml
application: sparepartsfinder
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /blog
script: main.py
- url: /blog/new_entry
script: main.py
- url: /blog/archive/.*
script: main.py
- url: .*
script: main.py
main.py
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write('Hello prueba!')
app = webapp2.WSGIApplication([('/', MainPage),
('/blog', MainPage),
('/blog/new_entry',MainPage),
('/blog/archive/.*',MainPage)],
debug=True)
Unfortunately it doesn't work either in local or when I try to upload the new configuration to the Google App Engine. ( I get always the same mistake).
I may understand the problem in my machine ( I have both Python 2.5 and 2.7 ) on a Windows XP, but not when I upload.
This is the error:
2012-05-04 13:02:07 Running command: "[u'C:\Python25\python2.5.exe', '-u', 'C:\Archivos >de programa\Google\google_appengine\appcfg.py', '--no_cookies', u'--email=salvador.sanjuan#gmail.com', '--passin', 'update', 'C:\Documents and Settings\SSanjuan\Mis documentos\Dropbox\Dropbox\Python\SpareParts']"
Error parsing yaml file:
Invalid object:
threadsafe cannot be enabled with CGI handler: main.py
in "C:\Documents and Settings\SSanjuan\Mis documentos\Dropbox\Dropbox\Python\SpareParts\app.yaml", line 27, column 1
2012-05-04 13:02:31 (Process exited with code 1)
Use main.application instead of main.py in your app.yaml. You need the former in order to set threadsafe to true.
I've been having the same problem, and here's the answer.
For the Python 2.5 runtime, you are specifying a path to a file -- ie script: myfolder/myfile.py.
For the Python 2.7 runtime, you are specifying an Object. So assumping myfile.py contains an appropriate WSGI object 'app', it's specified as script: myfolder.myfile.app.

Resources