Remoting Exception Handling: Internal Server Error retrieval on the client

Source: Internet
Author: User
Document directory
  • I have been using remoting Technology for some days. One of the problems has been bothering me, that is, the problem of obtaining internal server errors on the client. When the server and client are deployed on the same machine, server errors can be captured successfully on the client. However, once the server and client are deployed on two different machines, only one common exception can be caught on the client:
Remoting Exception Handling: Getting internal server errors on the client (reproduced in http://blog.csdn.net/oneiter/article/details/1616369) using remoting technology for development for some days, one of which has been bothering me, that is the problem about obtaining internal server errors from the client. When the server and client are deployed on the same machine, server errors can be captured successfully on the client. However, once the server and client are deployed on two different machines, only one common exception can be caught on the client:

System. runtime. remoting. remotingexception: the server encountered an internal error ......

This general error prompt clearly does not help the client to analyze the cause of the error. I modified the configuration file information on the server according to the error message, but the details of internal server exceptions still cannot be captured on the client. In addition, I had to add an error log file on the server to Write Remote Object exceptions to this log file. When an exception occurs on the client, log on to the server to view the log. This may be helpful for analyzing exceptions and finding errors, but the operation is inconvenient.

The day before yesterday, when I trained people from other departments of the company and talked about some basic remoting knowledge, I suddenly remembered that I had made a mistake in my previous project.

In the previous project, I used the Windows service as the remoting server host. A service framework is used to manage the remoting service registered to the server. When each service is registered on the server, I use code registration instead of configuration files. In this way, even if I add a. config file to the server, the configuration is as follows:

<? XML version = "1.0" encoding = "UTF-8"?>
<Configuration>
<System. runtime. remoting>
<Customerrors mode = "off"/>
</System. runtime. remoting>
</Configuration>

The internal error of the server is still not obtained on the client. To solve this problem, add two lines of code on the server:

// Remote throw Error
Remotingconfiguration. customerrorsmode = customerrorsmodes. off;
Remotingconfiguration. customerrorsenabled (false );

After testing, the problem is solved.

To sum up, there are two methods for obtaining internal server errors from the client, each of which has its own applicability.

1. When the server registers the service through the configuration file, that is

Remotingconfiguration. Configure (appdomain. currentdomain. setupinformation. configurationfile );

In the configuration file, add <customerrors mode = "off"/> under <system. runtime. remoting>.

2. When the server implements service registration through code, it is similar

Remotingconfiguration. registerwellknownservicetype
(
Typeof (remotingadminobject ),
"Remotingadmin ",
Wellknownobjectmode. Singleton
);

The following code is required:

// Remote throw Error
Remotingconfiguration. customerrorsmode = customerrorsmodes. off;
Remotingconfiguration. customerrorsenabled (false );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.