could not list books: Error 1046: No database selected - google-app-engine

1) I'm working through the bookshelf tutorial using Golang and Cloud SQL (MySQL).
Link to Tutorial:
https://cloud.google.com/go/getting-started/using-cloud-sql
2) I'm been able to deploy to app engine successfully.
3) I'm able to add, edit, delete books successfully in the cloud.
THE PROBLEM:
After a certain amount of time has elapsed, I get the following error message in the browser:
"could not list books: Error 1046: No database selected"
The problem goes away when I redeploy using the following command:
$ aedeploy gcloud preview app deploy app.yaml
QUESTION:
Any idea why this could be happening: Initial success followed by Error 1046 after a certain amount of time has elapsed?

Related

App Engine Cron Tasks fail with no entries in log. How to debug?

I recently updated my cron.yaml file and now my cron tasks fail with no entries in the logs.
It is acting like the java servlet at the url is not being run.
I can paste the url into a browser and the servlet runs fine.
My cron.yaml file:
cron:
- description: Daily revenues report
url: /revenues
schedule: every day 07:35
timezone: America/Denver
Using below deploycron.sh
PROJECT_ID='my-project-id'
gcloud config set project ${PROJECT_ID}
gcloud info
gcloud app deploy cron.yaml
Is there an error in my .yaml?
Is there a special task queue set up required?
Is some other configuration or permissions piece missing?
It was running fine last week. I have tried deleting and starting over to no avail.
https://console.cloud.google.com/cloudscheduler?project=project-id
Shows the job. Result column 'Failed'.
Logs 'View' link shows:
protoPayload.taskName="01661931846119241031" protoPayload.taskQueueName="__cron"
with no log entries.
Is __cron not automatic?
I am at a loss.
App Engine Standard. Java 8.
After installing the latest update of GCloud locally and re-running the deploy cron script. The cron jobs now run as before. 02/02/2021.
'Failed' means that the endpoint /revenues is not returning a success http status code.
Logs 'View' link shows: protoPayload.taskName="01661931846119241031" protoPayload.taskQueueName="__cron" with no log entries
Maybe don't use the premade filter, and just try filtering for /revenues or viewing all the logs at 07:35 am (when it was supposed to have run)
Is there an error in my .yaml?
if there was then gcloud app deploy cron.yaml would fail
Is there a special task queue set up required?
you shouldn't need to do anything, i didn't
I can paste the url into a browser and the servlet runs fine.
When you paste the url into the browser, is there any redirecting (like from /revenues to /revenues/) or anything that your browser is handling for you. Maybe /revenues is expecting there to be cookies present now.
What are there any special app.yaml or dispatch.yaml rules that /revenues would be hitting?
Is /revenues being handled by a service other than the default service?
I had a similar problem: CRON tasks fail without any logs.
The root cause was that the IP address of App Engine was blocked by the App Engine Firewall. Thus I had to update the allow-list, as described here: https://cloud.google.com/appengine/docs/standard/nodejs/scheduling-jobs-with-cron-yaml#validating_cron_requests
I started having the same problem a few days ago on my existing CRON schedules. I've tried everything including tearing my code down to the bare minimum and creating a new GAE project with the Hello World quick start. It still fails. Nothing useful in the logs and the UI just says 'Failed'. I'm pulling my hair out.
Sorry I don't have an answer to contribute but your post makes me think it's on Google's side. I know they're moving CRON jobs to Cloud Scheduler->App Engine Cron Jobs. My gut tells me it's a permissions issue related to this move and IAM. I'm really at a loss.

Unable to stop or delete datalabs environment on Google Cloud Platform

I cannot delete the datalab using the instructions found: https://cloud.google.com/datalab/getting-started#manage_instances_and_notebooks under Deleting VM instances. Keep getting error --
"Error: There is an operation pending for this application. Please wait and try again."
I keep trying after a period of time...but doesn't work. The charges to my account are growing and I cannot stop.
Already tried following: How to correctly stop Google Cloud Datalab
I finally deleted the entire project.

Google App Engine - Console Output

I am running a Java Microengine on GAE.
I have my own html pages for data input and output. When there is a data error and the engine cannot complete its execution (crashes) - the microengine spits out the "Response" as Server not available, please try later.
In order to debug, I run the dataset in the dev environment - as a Java application to identify the error in the console output.
Is there a way to capture the "error" (the console output equivalent when run as a Java application) - as an output string and send it as a content of the servlet response from the deployed Application in GAE..
thanks,
assuming you are using App Engine Managed VM, and a logging framework, you should also forward the log entry into a file, e.g. /var/log/app_engine/custom_logs/app.log
https://cloud.google.com/appengine/docs/managed-vms/custom-runtimes#logging
Subsequently, you'll be able to read the output from Google Cloud Logging.

Registration with Endpoints Server...FAILED! (emulator worked, phone doesn't)

Code generated by Android Studio>tools>Google Cloud Tools> Generate App Engine Backend
and Generate Endpoint worked in the Emulator,
Intent intent = new Intent(this, RegisterActivity.class);
startActivity(intent);
however I got this error (image from another person's question)
http://i.stack.imgur.com/230G2.png
when I load the app onto my phone and run. (I did change the LOCAL_ANDROID_RUN to false)
The error implies that there is some Endpoint server running at http://10.0.2.2:8080
which I don't expect because I don't really understand where the Endpoint Service runs. Does it run locally on the phone or somewhere on the Cloud?
I believe generated App Engine code is shipped up to Google through the Maven appengine:update
What am I missing here, thanks
-a
UPDATE (11:24 AM)
executed:
Android Studio>tools>Google Cloud Tools> Generate Client Libraries
which added to -AppEngine/target/generated-sources/appengine-endpoints etc
This changed what happened on the phone. There is still a registration error but now says:
2) registration with Endpoints Server...FAILED!
Unable to register your device with your Cloud Endpoints server running at https://.appspot.com/_ah/api
UPDATE (11:44 AM)
executed maven script
appengine:update to get the AppEngine deployed with the new code from Generate Client Libraries
same error on phone (unable to register your device with your Cloud Endpoints server)
UPDATE (1:39 pm)
got logcat info while running app on the phone, hooked up through USB to computer,
looks like a 404 Not Found error (???)
12-27 13:36:51.942 609-703/? I/InputDispatcher﹕ Delivering touch to: action: 0x1
12-27 13:36:52.412 19103-19103/sic.example.db7 W/AbstractGoogleClient﹕ Application name is not set. Call Builder#setApplicationName.
12-27 13:36:52.412 19103-19246/sic.example.db7 E/GCMRegistrar﹕ internal error: retry receiver class not set yet
12-27 13:36:53.253 19103-19246/sic.example.db7 E/sic.example.db7.GCMIntentService﹕ Exception received when attempting to register with server at https://core-phoenix-441.appspot.com/_ah/api/
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
Not Found
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:111)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:38)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1042)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at sic.example.db7.GCMIntentService.onRegistered(GCMIntentService.java:158)
at com.google.android.gcm.GCMBaseIntentService.handleRegistration(GCMBaseIntentService.java:296)
at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:197)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:61)
the emulator can access because it runs locally, your phone doesn't have access to the computer localhost. To do that you can check Codiak answer.
https://stackoverflow.com/a/16097253/1368396

Server Error in appspot.com application

Running my application on local with dev_appserver for finding event list from Google calendar and it works fine.
when I deployed through app-engine (deployment done successful) and when I run the file it gives me below error
Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.
Google lot about this error still unable to find solution for the same
my app.yaml file structure.
- url: /calendar
script: webserverflow12.py
When I run this appspot.com/calendar. It is giving me mentioned error.
Any idea what changes need to do to run my application on live?
I feel that you didn't changed your client id and client secret which u registered for appspot.com domain when deploying to appengine server. So you are getting this error.
Check your application logs from your GAE admin page.
Hopefully you'll find some info there to help debug.

Resources