How to create custom error handler for Mule domain project - runtime-error

I would like to catch exceptions when run/start domain project.
I have HTTP listeners configured in domain project, if port already used I want to catch those errors.

In Mule 4 you can not catch errors not related to the execution of a flow, ie System Errors. Those errors maybe printed in the log by the runtime, but their handling is not configurable. Even if it were there is no way to recover that kind of error. I recommend to setup some monitoring system to be sure the applications are behaving correctly. For example, to check that the port is open and listening to requests.

Related

Application Initialization IIS - Log Files

I have configured the Application Initialization for a Web App running on Azure, the reason for that is to improve the "warm up", because I have some issues with Scale-out, the instance is not ready for the connection then I got some servers errors.
There is a good doc from Microsoft about that:
https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-application-initialization
I am not sure how to check if Application Initialization is working.
Are there any logs that I can check?
IIS doesn’t provide separate log files for each modules and function, but for each website. So application initialization for a web to improve the “warm up”, can be checked by some function.
Advanced Logging is helpful and analyze the log file of the website which applied application initialization module. You can get it from here
Fail Request Tracing also can help you to trace request when you try to access the website to test whether the initialization is successful, especially using url rewrite with application initialization. Enable fail request tracing from here.

Web service call failing with 5xx type errors

We've inherited a .asmx web service without source code (my favourite).
We've run tests (calling it from a console app with fiddler attached) both internally and externally and it runs clean every time - as it does for the vast majority of our clients.
However, one user is reporting 5xx type errors. We've tried all the usuals (event viewer and IIS logs) but they're all clean. We can't get it to fail at all.
What further options do we have?
Can the clients replicate the error at will?
The error is most likely data related. Have you tested it with the same data that your client is to produce the error.
The error may also be at the client's end during serialization/deserialization of the call in their auto-generated asmx wrapper.
Has there been a change to the WSDL?
Things like ELMAH are great for logging all unhanded exceptions.
add logging to web config, log everything.
decompile the webservice and find the reason.

Catching Exceptions in background threads with Elmah

I have an MVC+SignalR application that has a lot of Reactive Extensions subscriptions flying around, all of which are projections of data coming from a Socket in realtime. Some of these subscriptions are not working as expected, and when they raise an exception it just goes into the void unless I'm debugging.
I had hoped that I could use Elmah to automatically log these unhandled exceptions, but it seems that unless the exception occurs on the same thread that's processing the request/response, eg it causes a yellow screen of death, Elmah isn't touching it. So my question is twofold:
Can I get Elmah to automatically log exceptions on background/worker processes?
If the answer to #1 is "no", what's my next best option, other than wrapping my subscriptions in try/catch blocks at a very high level?
Ad 1) If it doesn't happen already it probably doesn't.
I don't know how exactly you use background threads, but I will try to explain were ELMAH handling is working. ELMAH is integrated into ASP.NET pipeline, and when the error occurs it is handled by ASP.NET pipeline, which shows error page (like http error 500) and invoke ErrorLogModule. Moreover quoting Using HTTP Modules and Handlers to Create Pluggable ASP.NET Components -> Adding ELMAH to an ASP.NET Web Application
The section adds the ErrorLogModule HTTP module to the
ASP.NET HTTP pipeline. Make sure you include this
setting, otherwise ELMAH won't be listening for the Error event, and
therefore won't be logging any unhandled exceptions.
Ad 2) Because you are using Reactive Extensions you can handle onError in which you can automatically log into Elmah. If you don't want to writer everywhere error hangling in OnError, just create your own function or method extension which will wrap it automatically for you. Writing into ELMAH manually is simple just call:
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);

How to log errors in APIGee

Is there any error logging option in APIGee?
I am enabling a proxy endpoint in APIGee for a customer. If there is any error in the flow, how can I log it to a persistent store?
Specifically, I am using javascript policies and parsing some of the returned by back-end service, format to a different format. If there is any parsing error, where and how can I log it?
I am able to catch the error with try catch block.
Can I send an email in the catch block to a specific email address?
Thanks,
Deepak
You can catch the error in your catch block and then set the appropriate variable to contain the detailed error message you might have ran into.You can use syslog/messagelogging policy to send all the request details along with any parsing exception that you might have. You need some kind of a logging server at your end to be sent the logs to or you could also use public log management services, such as loggly. Refer to this section for more details - http://apigee.com/docs/api-services/content/log-messages-using-messagelogging
Vineet I think you are looking to solve the following problems here:
During the coding process you want to debug and understand what is going on? Something that lets you log.debug equivalent.
You want to also trigger exception flows or external processes when things go wrong in your proxy flow.
For #1 you can assign variables and trace using apigee's debug view. Any flow variable assignment in Apigee policies is printed in the debug view, if the policy is executed. So that provides you with log.debug mechanism, whenever you trace.
For #2 you can take a variety of approaches based on rest of your systems and processes. The previous answer by #Mike Dunker is a good approach. I can suggest a few more alternates
As an alternate you can also use Apigee's analytics views to monitor errors, albeit after the fact.
You can set up external monitoring scripts on your backend or on the apigee endpoint based on some synthetic transaction that touches upon the entire logic of your flow. When the services return error you can measure metrics and/or raise alert from your monitoring system.
If you have an on-premise installation of Apigee, you may want to consume apigee log files on the servers and raise appropriate actions on errors.
You can raise a desired error message to a JMS queue when error happens. Refer to Apigee's JMS support here

How can I find out more diagnostic information from a failed web service call?

When calling an asp.net web service from a windows mobile device project, I am catching an exception ( WebException ) and the response inside that seems to be "BadRequest".
This is occurring on a live system but not locally in development. But they both have the same build....
When we point our development code at the live web service we get the BadRequest error again. Is there any way I can get more information about this error?
We use Elmah for logging and can confirm no exceptions are being thrown in the web service itself, in fact, it isn't even getting invoked!
Bad Request is a generic error which means the server didn't even bother looking much at the request from the client because it was significantly malformed in some way (service receive buffer lengths exceeded, etc.).
Try to send the server something simpler from the client until it works and/or gives a different (more precise) error.
Unfortunately, server exception handling or viewing traffic on the wire with a tool like Fiddler is probably not going to be helpful in this scenario.
It would help to know which version of web services this is (ASP.NET 2.0, WCF, etc.).

Resources