I have an App Engine Python Application which has an endpoint that puts a task in the Task Queue. - This is working fine.
I have a Task Handler Python Application which will be execute the task in the queue.
When the task handler is invoked, the below error accurs
Request failed because URL requires user login. For requests invoked within App Engine (offline requests like Task Queue, or webhooks like XMPP and Incoming Mail), the URL must require admin login (or no login).
My App Engine Python Application app.yml is below
service: dataload-test
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
- url: /_ah/queue/deferred
script: google.appengine.ext.deferred.deferred.application
login: admin
libraries:
- name: ssl
version: latest
builtins:
- deferred: on
- appstats: on
env_variables:
GAE_USE_SOCKETS_HTTPLIB : 'true'
My Task Handler Application app.yml is below
service: adobe-dataload-worker
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: load_data_worker.app
login: admin
Any help would be appreciated
Your wildcard - url: /.* handler is handling EVERY URL.
Put that last, or else the deferred handler will never be seen:
handlers:
- url: /_ah/queue/deferred
script: google.appengine.ext.deferred.deferred.application
login: admin
- url: /.*
script: main.app
Related
I was working on google Pubsub with App Engine, to get notifications from google play about InApp subscriptions status.
When I deploy my app with the command "gcloud app deploy", error message comes:
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/home/testaccount/php-docs-samples/pubsub/app/app.yaml]
Unable to assign value 'pubsub.js' to attribute 'url':
Value 'pubsub.js' for url does not match expression '^(?:(?!^)/.|..|((.).*(?!$).)$'
in "/home/testaccount/php-docs-samples/pubsub/app/app.yaml", line 6, column 8
My app.yaml file:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: pubsub.js
static_files: pubsub.js
- url: /.*
script: index.php
env_variables:
GOOGLE_PROJECT_ID: "testproject"
I have followed the insturctions in the linl:
Writing and Responding to Pub/Sub Messages
I did not modify app.yaml file, I do not know what is going on? I tried to deploy "Hello, World!" for PHP on App Engine" exmaple and it worked.
Please help me to solve it.
url should start with a slash. Try:
- url: /pubsub.js
static_files: pubsub.js
After a week searching about why I get HTTP error 500 (Internal Server Error) when I browse https://testproject.uc.r.appspot.com/, I got the reason, it was from app.yaml file, all errors came from php version.
Old app.yaml:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /pubsub.js
static_files: pubsub.js
upload: pubsub.js
- url: /.*
script: index.php
env_variables:
GOOGLE_PROJECT_ID: "testproject"
New app.yaml:
runtime: php72
handlers:
- url: /pubsub.js
static_files: pubsub.js
upload: pubsub.js
- url: /.*
script: auto
env_variables:
GOOGLE_PROJECT_ID: "testproject"
Thank God.
I have one dispatch.yaml that splits 2 services; admin_main.py that controls the admin login, and main.py that controls the user landing. My problem is that admin_main.py does not see its own CSS that I directed it to it. However, it keeps matching with the main.py CSS.
my files are structured as
admin
|assets
|CSS
+styles.min.css
www
|assets
|CSS
+styles.min.css
dispatch.yaml:
dispatch:
# Default service serves simple hostname request.
- url: "example.net/"
service: default
# Default service serves simple hostname request.
- url: "app-example.appspot.com/"
service: default
# Default service serves simple hostname request.
- url: "admin.example.net/"
service: admin
- url: "admin-dot-app-example.appspot.com/"
service: admin
admin_main.py:
service: admin
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /assets/css/styles.min.css
static_files: admin/assets/css/styles.min.css
upload: admin/assets/css/styles.min.css
- url: /.*
script: subdomain.app
libraries:
- name: webapp2
version: latest
- name: jinja2
version: latest
main.py:
service: default
runtime: python27
api_version: 1
threadsafe: yes
default_expiration: "4d 5h"
handlers:
- url: /assets/css
static_dir: www/assets/css
- url: /assets/img
static_dir: www/assets/img
- url: /.*
script: main.app
libraries:
- name: webapp2
version: latest
- name: jinja2
version: latest
in the .html the links to the CSS are
<link rel="stylesheet" href="assets/css/styles.min.css">
for both landing sites. But that shouldn't be a problem since the dispatch.yaml separate the incoming calls, right?
I'm not really sure what is causing the problem. Also, I'm new to yaml and I been reading it's documentation.
One solution for this is to store every CSS in the same file, and give them different names. Then in app.yaml in the handlers section add this:
- url: "/assets/css/(.*\\.(css))$"
static_files: {CSS_DIR_IN_PROJECT}/\1
upload: {CSS_DIR_IN_PROJECT}/.*\.(css)$
application_readable: true
that was my only way of solving the problem
Our GAE/Go application returns 401 response to /_ah/start like below.
app.yaml is this.
runtime: go
api_version: go1
application: (out app)
version: 777
threadsafe: true
manual_scaling:
instances: 1
handlers:
- url: /_ah/.*
script: _go_app
- url: /.*
script: _go_app
login: required
secure: always
Why we have this error? How can I fix this?
We know deleting manual_scaling can fix this error, but we would like to restrict the number of our instance.
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.
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