Calling Google App Engine endpoint from Google Pub/Sub - google-app-engine

I created a Google Pub/Sub push subscription which points to a Google App Engine endpoint, but GAE is not receiving anything.
The messages are being published (I can see it on the Pub/Sub console), but never acknowledged.
The endpoint URL should be correct since I made my GAE endpoint public and tested using Postman.
Does Google Pub/Sub not support calling Google App Engine endpoints?
Or I'm I missing something here?
Appreciate it someone could help with this.

For a message to be acknowledged, it means it has to be received by the subscriber. How are you trying to do this? I ask because GAE (at least GAE standard) doesn't support streaming which means you can't have an indefinitely open connection listening for messages from pubsub.

Yes Google Pub/Sub supports calling to Google App Engine endpoints. I referred to this documentation.
As per the document, I used App Engine Flex Environment with Pub/Sub push subscription and I am able to fetch the messages that were published from Pub/Sub to the endpoint.
You can refer to the below mentioned steps :
Create one application using App Engine Flex Environment by referring to this document.
Deploy the application to GCP .
The files needed for application deployment are app.yaml, requirements.txt, main.py and index.html file inside a template folder.
Folder structure:
Demo→
app.yaml
requirements.txt
main.py
templates→
index.html
Provide the Pub/Sub topic name and token id ( should be the same as Pub/Sub push endpoint token id ) in the app.yaml file.
env_variables:
PUBSUB_TOPIC: your-topic
PUBSUB_VERIFICATION_TOKEN: 1234abcd
Run gcloud app deploy on the demo directory.
After the application is deployed, you will get an endpoint URL with the format : https://PROJECT_ID.REGION_ID.r.appspot.com
Example: https://mydemoproject.uc.r.appspot.com
Create a Pub/Sub topic and subscription and make the delivery type as push.
We need to provide a push endpoint with the format : https://mydemoproject.uc.r.appspot.com/pubsub/push?token=1234abcd
When an application is deployed in App Engine we can access that application at - https://PROJECT_ID.REGION_ID.r.appspot.com
The messages will be received by any of the instances of your application deployed in App Engine.
SSH into your instances and use the App Engine endpoint URL in the VM.
Output of instance 1:
Output of instance 2:

Related

Block Requests based on UserAgents with Google Cloud App Engine

my website is hosted with google cloud app engine. I have an increase request amount from the same user agent. Is there a possibility to block specific incoming requests with app engine, e.g. through the app.yaml file? I don't find anything related to that in the documentation.
Thanks in advance

Disable recording IP address in google app engine logs

Is it possible to make configurations in Google app engine for not recording IP addresses from clients to the Java application in stackdriver logs?
No, you cannot configure or opt-out from request logs, where the client IP addresses are recorded. From Using Stackdriver Logging in App Engine apps:
The App Engine standard environment produces the following logs:
Request logs, appengine.googleapis.com/request_log, called request_log in the Logs Viewer. This log records requests sent to
all App Engine apps. The request log is provided by default and you
cannot opt out of receiving it. For more details, see the RequestLog
type.
...
The App Engine flexible environment produces the following logs:
Request logs record requests sent to all App Engine apps. The request log is provided by default and you cannot opt out of receiving
it.

Does Google cloud image repository send out notifications on any push/pull of images on/from the repository?

The docker repository provides notifications to an endpoint, when any image is push/pulled from a private repository (https://docs.docker.com/registry/notifications/#configuration). Does Google Cloud image repository provide some similar notification mechanism? The document talks about publisher application which will publish the message to pub-sub, but it is not clear to me - 1)whether GCR will directly publish the message to pub-sub 2) if not, if I have to write an publisher application how will it get know about any changes on my repository. I might be missing something really rudimentary here, please help me understanding the flow.
You can use Cloud Pub/Sub:
https://cloud.google.com/pubsub/docs/overview
Yes Cloud Registry messages will be publised to Cloud Pub/Sub.
The steps to follow to use Cloud Pub/Sub notifications with Docker are:
Create a Pub/Sub topic
$ gcloud alpha pubsub topics create projects/[PROJECT-ID]/topics/gcr
Create a pub/sub subscription
gcloud alpha pubsub subscriptions create [SUBSCRIPTION-NAME] --topic=gcr
Configuring Pub/Sub access controls in the GCP Console's IAM page
https://cloud.google.com/pubsub/docs/access-control#console
You can use one of the following roles:
Owner, Editor, PubSub/Admin, PubSub/Editor, PubSub/Publisher, PubSub/Subscriber
The Container Registry notifications will be shown in the pub/sub section withing your project.
You can check this documentation on how to configure Cloud Pub/Sub notifications
https://cloud.google.com/container-registry/docs/configuring-notifications
Here is a quickstart guide to understand better how Cloud Pub/Sub works
https://cloud.google.com/pubsub/docs/quickstarts

Google PubSub: SSL error when subscribing using an AppEngine push endpoint

I created a topic which I subscribe to using a push endpoint. The endpoint is a simple AppEngine web service. The Google PubSub documentation states that endpoints must be secured by HTTPS.
I am not receiving any traffic to the push endpoint. The AppEngine web service shows no requests. I've verified through the Google PubSub dashboard that messages are being published on the topic successfully. The dashboard shows unreachable_ssl_error for push subscriptions. Why is Google PubSub reporting this error?
When I try to access the SSL AppEngine endpoint via a browser I receive an SSL cert error also. Is this normal for AppEngine sites?
As documented at https://cloud.google.com/appengine/kb/general#https , SSL is supported on App Engine, but in a somewhat peculiar way.
Specifically, and I quote...:
Note: After April 2013 Google does not issue SSL certificates for
double-wildcard domains hosted at appspot.com (i.e. *.*.appspot.com).
If you rely on such URLs for HTTPS access to your application, change
any application logic to use "-dot-" instead of ".". For example, to
access version v1 of application myapp use
https://v1-dot-myapp.appspot.com.
Also look at the previous paragraph at this same URL about the need for secure in app.yaml and a link to language-specific instructions on exactly how to configure things, e.g https://cloud.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Secure_URLs if you're programming in Python.

Google App Engine Backends not associated to any Frontend

I'm developing a Java app in GAE, which offers an API through Google Cloud Endpoints.
Basically it receives requests in the endpoints and uses a number of web services from different providers, stores some data and returns some data through the endpoints...
I understand that my app is conceptually a backend, because it doesn't provide any web page, but only the endpoints, don't you think so?
But there's no way to create only a backend, without being associated to any frontend app, is there? At least Google Plugin for Eclipse only allow you to "Generate App Engine Backend", from an existing app, and moreover this app must be an Android project...
I'm using it as a frontend and there's no problem, but apart from the conceptual issue, I've read that backends are kind of optimized to be backends, with more memory and CPU...
I think you're just confused because the Cloud Endpoints documentation uses the word 'backend' to refer to the entire cloud-hosted server implementation. It doesn't specifically refer to the use of GAE backend instances. Endpoint requests can be served by frontend or backend instances, based on how you set them up and the url being accessed.
From the App Ending docs:
"When an application is called to serve a web request, it must issue a response within 60 seconds"
"App Engine Backends are instances of your application that are exempt from request deadlines and have access to more memory (up to 1GB) and CPU (up to 4.8GHz) than normal instances."
So unless you're requests are doing something crazy, you don't need to use a backend. In the google-plugin-for-eclipse, "generate appengine backend" is talking about creating a backend for your android app... a server for your android app to contact (in this case your android app is the frontend and you're appengine app is the backend). In the example app you can remove the web side (index.html) to the appengine application and you'll have no web frontend. Index.html is using the gapi javascript library to make endpoints calls to your appengine service.

Resources