What is the solution for the error when I deploy pubsub for PHP with App Engine? - google-app-engine

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.

Related

GCloud Error: Not Found The requested URL was not found on this server

I followed this steps to deploy my angular 8 application in Google Cloud
https://medium.com/#karthiksagar/how-to-deploy-angular-8-app-on-google-cloud-platform-gcp-cdd79e5cc5cf
My app.yaml is as follows
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: sofbox-angular/index.html
upload: sofbox-angular/index.html
- url: /
static_dir: sofbox-angular
I have placed the app.yaml file inside dist/ directory as mentioned.
I am able to access the main url- http://www.myridemate.com/
but when clicked on blog the link is not accessible - http://www.myridemate.com/blog
It gives below error
Error: Not Found The requested URL /blog was not found on this server.
Tried adding extra handler for /blog in app.yaml and it didn't work.
This same code is working in my local and also in hostgator - https://www.myridemate.alexvijayraj.com/blog
Not sure what I am missing here. Is there some extra configuration required in app.yaml or anything in GCP?
Error Message in App Engine Logs:
{
"time": "2020-09-17T03:58:28.682252Z",
"severity": "WARNING",
"logMessage": "Static file referenced by handler not found: sofbox-angular/blog"
}
The answer in this thread worked for me. Angular 6 routes not found on Google App Engine
Remember to remove the two handlers that are already on the .yaml file (-url: ...)
handlers:
- url: /(.*\.(js|css|svg|png)(|\.map))$
static_files: dist/\1
upload: dist/(.*)(|\.map)
- url: /.*
static_files: dist/index.html
upload: dist/.*

URLs not found after deploying create-react-app build to Google Cloud Platform

I've uploaded a create-react-app build (with an app.yaml file) to a GCP bucket. The app has then been deployed on a App Engine instance using the cloud shell.
Going to the app's root URL works fine. But going to example.com/anything returns the following error:
Error: Not Found
The requested URL /anything was not found on this server.
App.yaml file looks like this:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(html|css|js))
static_files: build/\1
upload: build/(.*\.(html|css|js))
- url: /
static_files: build/index.html
upload: build/index.html
You don't have a handler for /anything. If you want a catch-all url, use regex type handler:
- url: /.*
static_files: build/index.html
upload: build/index.html
or, if you want to serve them anything.html as a static file, put it in your build dir, and navigate to /anything.html. Your first handler is set up to map that url.

GAE/Go: /_ah/start returns 401

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.

404 page doesn't show when accessing a missing file in a static directory

I'm working on porting my blog from GitHub pages to Google App Engine. I've set up my app.yaml as follows.
runtime: python27
api_version: 1
version: 5
threadsafe: yes
handlers:
- url: /api/.*
script: main.app
- url: /
static_files: src/_site/index.html
upload: src/_site/index.html
- url: /(.*)/
static_files: src/_site/\1/index.html
upload: src/_site/*.*
- url: /(.*)
static_files: src/_site/\1
upload: src/_site/(.*)
error_handlers:
- file: static/404.html
You can get to my 404 page directly by going to http://joshuasnidercom.appspot.com/404.html and you can get to by accessing a missing page that the flask app handles like http://joshuasnidercom.appspot.com/api/invalidurl, but going to any page that is covered by the static files like http://joshuasnidercom.appspot.com/nonexistentpage just shows a Error: Not Found The requested URL /nonexistentpage was not found on this server. error.
What should I be doing differently?
I believe you need to create an error handler in your views file.
You can do this with the following code:
#app.errorhandler(404)
def page_not_found(e):
return render_template("404.html"),404
You can also replace 404 with 500, 403, etc,for other errors.

Google app engine running error

When I was trying to run one of the application on google app engine I keep on getting a yell icon the means error. How can I fix it ,so I can run my application.
The error is one the left end side of hello-udacity
Here is the link of the picture of the error: https://plus.google.com/u/1/115545843446144625696/posts/aoRyoN2r2Sd?pid=6168940381509733874&oid=115545843446144625696
In main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello udacity!')
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
In app.yaml
application: hello-udacity
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.2"
The app.yaml file uses the YAML syntax and so your app.yaml should comply with those. The following is a clearer configuration
application: hello-udacity
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.2"
For more on this see about app.yaml in the developer docs

Resources