Google Cloud Platform random 404 on endpoints - google-app-engine

I have two apps deployed on google cloud. One exposes an api, that is consumed by the other.
But, sometimes, some of the request return a 404 http code. I cannot find a pattern to reproduce it yet. Any idea?
404 Cannot POST {link-to-api}

Related

Google App Engine and GCP Load Balancer request inspection

I have an API running in Google App Engine and I want to introspect HTTP POST body to reject poorly formed calls before it hits my API running in app engine. Is there a way to front an App Engine application whereby I can introspect the URI, the POST body and return a 400 without it actually being processed by my code running in App Engine? Please let me know, thanks.
If you want to inspect HTTP, then you will need to write a proxy application to do so. Neither the Google Cloud Load Balancer nor App Engine support hooking HTTP requests.
Proxies have the MITM (Man In The Middle) problem in that HTTP traffic is often encrypted. You will not be able to inspect that traffic unless your proxy is the endpoint. If you implement your proxy with Apache or Nginx then you can use the ModSecurity project.
Basically, you want to implement a WAF. Google offers Cloud Armor which supports inspecting traffic via Cloud Armor rules.

Google Cloud Loadbalancer not working with App Engine Blobstore

We've just created a new Loadbalancer which works perfectly well with all our services. The only issue we have is with the Blobstore.
The initial blobservice request works - returning a URL for the upload. But executing that request (/_ah/upload/) fails with a 404. My understanding is that it should be redirected to the blobstore service which will then send a response with the upload id. This works fine without the load balancer.
I can't see a way to add the blobstore as a service, so I don't know what to do to make sure the request is routed to the correct place.
Any help is gratefully appreciated!
This is currently a known limitation with Blobstore when used in an HTTPS load balancer in App Engine.
With the App Engine to Blobstore service, the generated URL for upload is shared to Google Front End. When the Load Balancer is introduced, the App Engine URL is returned, and causes a 302 redirect. The returned URL is used as a relative path to connect via the load balancer, and as it is not aligned to the one expected by the GFE, a 404 response is thrown.
Blobstore is a legacy API and has been deprecated, and with the limitations it has, it is ideal to look for alternatives.
You can consider using Cloud Storage, as mentioned in this overview. It is possible to achieve the upload behavior through Cloud Storage signed URLs which bypasses the App Engine Upload component. It would be necessary to implement a further component to notify on completion, such as a Pub/Sub for new object creation, if that information is needed.
Besides Cloud Storage, you can check other replacement options for Blobstore in this documentation.

https on google cloud works intermittently

Im using HTTPS provided by Google Cloud with an App Engine project.
And https://example.com works intermittently.
Many a times I see the error unable to connect.
But https://example.appspot.com will be working.
How to resolve this ?

deployed appengine cloud endpoints 403

My deployed site cant reference endpoints. It works perfectly locally but remotely I get a 403 in the client:
GET http://mailmanagerplus.appspot.com/_ah/api/discovery/v1/apis/agreement/v1/rpc?fields=methods%2F*%2Fid&pp=0 403 (Forbidden) rs=AItRSTOc4KBtnc5SIOEaPiMWPOclVYHqsA:153
All seems to have deployed successfully looking at the logs. I currently don't use any authentication.
Any direction would be useful as I'm very new to this.
you have to switch to "https" protocol if you want to use endpoints client library on the production.

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