WCF communication between two servers crashes after IIS7 processing

I was kind of embarrassed by this, and hoped that I would find a few answers here.

Basically, I have an ASP.NET application running on two servers. Server A has all the available business logic / data access in the form of web services, and server B has a website that talks about these services (via WCF with net.tcp binding).

The problem occurs a few seconds after IIS on server A. initiates a restart of my application pool. Recycling occurs after the allotted time (using the default 29 hours in IIS).

In the server log (server A):

Workflow with process identifier application pool #### '' AppPoolName "requested processing because the workflow has reached its allowable processing time.

I think this is normal behavior. The problem is that after a few seconds I get this exception on server B:

This channel can no longer be used to send messages as the output session was automatically closed due to server shutdown. Either turn off auto-closing by setting DispatchRuntime.AutomaticInputSessionShutdown to false or consider changing the shutdown protocol with a remote server.

This does not happen on every repetition; I suppose this happens when someone hits the site with a WHILE request when processing happens.

In addition, my application does not work until I intervene; this exception continues to occur every time the next request is made to the page. I intervene by editing web.config (adding a space or something benign at the end of the file) and saving it. I assume this forces my application to recompile and returns the services back. I also experimented with running a batch file that does this for me every time an exception occurs;)

Now I could hardly find information about this exception, and I was looking for a while. Most of the information I found relates to WCF settings, which I do not use.

I already read "DispatchRuntime.AutomaticInputSessionShutdown" and I do not think this applies to this situation. This particular property refers to disabling a service automatically in response to client-side behavior, which is not what happens here. Here the service is disconnected due to IIS.

I read this one that went through some work to automatically return the service, but I really want to understand what is happening here, and not hack it!

I started playing with the settings in IIS7, in particular turning on / off Overlapped Recycling and increasing the start / end time of the process. I am wondering if recirculation can be completely turned off (I suppose if I set 0 for the recirculation time interval?) But again, I want to know what happens!

In any case, if you need more information, let me know. Thanks in advance!

+4
source share
3 answers

This is probably due to the way you open and close WCF connections.

If you open the proxy server at the start of your application and continue to use it, this will lead to a connection interruption caused by a server-side restart. Results with an error on the client side, since the server that the proxy server was talking to no longer exists.

When the client part is restarted (with web.config changed), new proxies are created on the server that is running.

To fix this, make sure you close the WCF connection after using it.

http://www.codeguru.com/csharp/.net/net_wcf/article.php/c15941/

+4
source

You must also ensure that you are using the correct SessionMode for your web service. I remember that I had problems with some of my Services until I figured out the correct mode. This is especially true when you mix this with any other authentication mode that is not "No."

This link may have some pointer.

http://msdn.microsoft.com/en-us/library/ms731193.aspx

0
source

My suggestion is simply to stop using IIS to host your services. Unless you really need something from IIS, I would recommend just writing a standard Windows service to host WCF endpoints.

If you cannot do this, then be sure to turn off the recirculation. AppPool recycling basically exists because web developers write crappy code. I know this sounds rather rude, but if you have enough sense to write code that does not flow, then there is no reason for IIS to constantly restart your program.

0
source

Source: https://habr.com/ru/post/1299201/


All Articles