How do I display an exception's full stacktrace in Google App Engine's app log? - google-app-engine

While detaching an object from the datastore in a deployed app on Google App Engine, I'm getting an "failed to detach" exception that I can't reproduce on my development box. The detach operation is server-side, so the only information I have on it is the log of the exception in the app's log files. However, the stacktrace is elided: for example, the deepest internal exception ends with "... 36 more".
How do I adjust the verbosity of the app's logging to include the full, non-elided stacktrace?

What you can do is to add the Throwable as a parameter when logging an exception. ie:
Logger log = Logger.getLogger(YourClass.class.getName());
.....
}catch (final Throwable e){
log.log(Level.SEVERE, e.toString(), e);
}
This will print a nice stack trace on GAE's logs.
This way you don't have to change the global log level.

There are few things that you can possibly tweak:
1) In war\WEB-INF\logging.properties file. Change the .level value to a level lower e.g. DEBUG.
2) In your Java code, look at encapsulating the problem code within a try/catch so that you have control of the same.
3) In the catch block, look at logging the exception data via ex.printStackTrace(), where ex is the exception object.

Related

Google Error Reporting does not correlate to parent http request

I'm using Google App Engine Standard with Python 3. When i click on an error in Google Error Reporting and then click "View Logs", I get taken to Google Logs Viewer/Explorer with something like this error_group("CObpg_HTfjskb6GA") as a search filter.
I see the individual log line with the stacktrace but not any logs for the parent request for which this occurred.
In the docs, they have a screenshot where it does look like we should be able to see the parent http request in which the error occurred: https://cloud.google.com/error-reporting/docs/viewing-errors#view_associated_log_entries
Right now when I need to look into an error, I have to do a separate search in logs explorer with part of the error message (in the case of the above example I'd search for "KeyError: 'c'") to find a duplicate log that has a trace id set. Then I'd be able to 'show all logs for trace' and be able to finally see all the logs that lead up to this error.
This feels related to this other issue from before, where logs in general in python3 were not getting correlated like they were in python2: How to group related request log entries GAE python 3.7 standard env
Logs now get grouped together via trace, but as far as I can tell, I cannot set trace on error report logs.
I have my logging setup by doing:
client = google.cloud.logging.Client()
client.setup_logging()
For error reporting I was just getting error reports from google.cloud.logging's integration with the python logger:
try:
# code where an error occurs
except Exception as exc:
logging.exception(exc)
raise
I've now started trying to use google-cloud-error-reporting to see if maybe there are some options in there that I can set to get it to correlate, but I seem to only be able to set a HttpContext & ReportingLocation. There isnt a spot for me to set trace or anything like that.

Hosting Company under cyber attack!! Can I fix this myself or do I wait for the hosting company?

Our hosting company MijnHostingPartner.nl got hit badly by a cyber attack and most of their client's website have been down for weeks. I am a complete noob in coding, just working my way around it by using DNN to build a website. I've set up all the MSSQL DB's correctly and it's running smoothly for over a year now.
Since it's used daily by a small community of ten pin league bowlers - all results and news are displayed here - I'm getting quite the amount of complaints since it's down!
This is the error I get on both top-level as sub-level domains:
Server Error in '/' Application.
No http handler was found for request type 'GET'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: No http handler was found for request type 'GET'
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): No http handler was found for request type 'GET']
System.Web.HttpApplication.MapIntegratedHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig, Boolean convertNativeStaticFileModule) +748
System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +589
[HttpException (0x80004005): Error executing child request for ~/ErrorPage.aspx.]
System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveForm) +1295
System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm) +72
System.Web.HttpServerUtility.Transfer(String path) +45
DotNetNuke.Common.Initialize.CheckVersion(HttpApplication app) +845
DotNetNuke.Common.Initialize.InitializeApp(HttpApplication app, Boolean& initialized) +154
DotNetNuke.Common.Initialize.Init(HttpApplication app) +157
DotNetNuke.HttpModules.RequestFilter.RequestFilterModule.FilterRequest(Object sender, EventArgs e) +258
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +88
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0
Does anyone have a clue what I'm talking about? 'Cause I sure don't. Please, if you explain it to me, explain in a way your dog would understand, if that's even possible.
Many thanks,
Robbe
If you are using a third-party hosting solution I would guess that you don't have the ability to change the values referenced in the comments section.
This error appears to be a very low-level issue with the server not being configured for ASP.NET hosting. (The underlying technology used by DNN.)
I'm not confident that you will have the ability to fix this without them. However, you have a few options.
Get the information on this error to the hosting provider. The key will be to determine if ANY services work A great check is to see if you can get the DNN Keep Alive to work. You can get to that via http://yoursite.com/keepalive.aspx
Extract a copy of the site files & database and move to another host. This is typically an easy option, but I would caution you that it would be prudent to have the site scanned for any potential malicious impacts PRIOR to moving to a new hosting provider unless you know for sure what the impact was to your hosting provider.
This is never a good situation, but one that you should be able to get past. If needed, this could be a time to reach out to someone that knows this stuff well, as there are a lot of little risks associated with a potentially compromised solution.

Google App Engine: FileServiceImpl.translateException on closeFinally()

This may be related to Google File Service closeFinally() timeout.
My Java GAE app is running on SDK 1.8.2 and is hitting a translateException when calling closeFinally() on a FileWriteChannel. I'll be updating the SDK and migrating to the new Cloud Storage API but need to resolve this exception asap for a customer so am wondering if anyone has some insight into the issue for a quick fix.
Here's a simplification of the code that's causing the issue:
AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());
String gcsWritePath = writableFile.getFullPath();
FileWriteChannel writeChannel = fileService.openWriteChannel(writableFile, true);
for(conditions) {
Do stuff and write to gcsWritePath
if(recordsWritten > threshold) {
Kick off new task with a startAtparam to avoid OOM and timeouts
break;
}
}
if(all records written) {
writeChannel.closeFinally(); // Exception happens here
}
And the exception details
java.io.IOException
at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:621)
at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:594)
at com.google.appengine.api.files.FileServiceImpl.close(FileServiceImpl.java:565)
at com.google.appengine.api.files.FileServiceImpl.close(FileServiceImpl.java:457)
at com.google.appengine.api.files.FileWriteChannelImpl.closeFinally(FileWriteChannelImpl.java:97)
The exception only appears to occur for longer running tasks (e.g. 5+ minutes) so it looks like this might be a timeout. I've tried adjusting the threshold without much luck though. I also tried looking through the app engine sdk source for FileServiceImpl.java and ApiProxy.java but didn't find any good clues.
Does anyone have any ideas as to what might be causing this?

Google App Engine - connect debugger on production

I have a production issue with a GAE application. The problem seems to be related only to some users.
Is there a possibility to connect the local debugger to the prod version ? I'd like to avoid to have to copy the prod data to the dev server.
Thanks !
This situation has improved as of a few days ago with the intoduction of Google Cloud Debugger
Earlier this week at Google Cloud Platform Live, we launched the beta release of Cloud Debugger which makes it easier to troubleshoot applications in production. Now you can simply pick a line of code, set a watchpoint and the debugger will return local variables and a full stack trace from the next request that executes that line on any replica of your service. There is zero setup time, no complex configurations and no performance impact noticeable to your users.
Here's the blog post
Here's the info
Not possible, you can only debug using the logs.
I managed to solve the issue. The problem was that one program was throwing an exception and I did not catch it properly. The code was
catch (Exception e) {
e.printStackTrace();
}
On the development platform the exception was thrown at the console. The problem in production is that it does not appear in the GAE console. This has two very bad outcomes :
--> 1) The end user does not know that the transaction did not end successfully
--> 2) The administrator has no clue that a problem has occurred and no way to debug
==>
I have therefore replaced the code by
catch (Exception e) {
final Logger log = Logger.getLogger(InternalServiceImpl.class.getName());
log.severe("Problem while updating XXX record : " + e.getLocalizedMessage());
updatedRecord.setRPCResult(DB_PROBLEM); // This is specific to my application to notify the end user
}
I did modify the code relaunched the application and found out that the problem was a resource contention in a transaction.
Was really a stupid beginner mistake.

WebClient fails with remote server "NotFound"

I'm building a wp7 app. I'm using WebClient to grab data from a server. In the past, it's been working, although all of a sudden it's failing.
static void downloadData(string uri, Action<object, DownloadStringCompletedEventArgs> onComplete)
{
Debug.WriteLine("Downloading: " + uri);
WebClient data = new WebClient();
data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(onComplete);
data.DownloadStringAsync(new Uri(uri));
}
static void data_SectionDownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
// throws NotFound
throw e.Error;
}
// ...
}
When I go to the URI in question in my browser, it works fine.
The exception:
"The remote server returned an error: NotFound." {System.Net.WebException}
What am I doing wrong here?
Update: I restarted the emulator, and now it works fine. Weird. Maybe it's an issue in the emulator? Hopefully I won't be able to reproduce it on the actual device.
NotFound is a generic error that basically means 'Error'. There is a real exception behind it that you need to dig to find. The easiest method I have found is Intellitrace which allows you to view every exception that ever happened on your web server. If you look just before your NotFound, you will find the real exception that backs it.
If Intellitrace is not an option, add more/better logging on your server and client. Google has many tips, a good example of deeper debugging:
http://www.mostlydevelopers.com/blog/post/2009/01/14/debugging-tips-ndash3b-the-remote-server-returned-an-error-notfound.aspx
I had similar experience with the emulator. I often open Internet Explorer and browse a site before I test any application that uses the network. Also, it is best not to change the IP address of the machine running the emulator, DHCP or manually. Lastly, I would suggest you handle any error scenarios with an error message displayed in a MessageBox.
HTH, indyfromoz
I get this occassionaly too. Even on real devices. A retry usually fixes it though.
Unfortunately this is one of the issues you need to be aware of and write code to cater for when working in an occassionally connected environment.

Resources