WCF - Binding.ReceiveTimeout & ReliableSession.InactivityTimeout

╄→尐↘猪︶ㄣ 提交于 2019-12-10 15:32:04

问题


I am trying to make a WCF service which uses callbacks to the client. I would like the channel to be kept open as long as there is a connection (internet, network) and either the client or channel have not explicitly closed the channel.

In order to keep the channel open (even without activity) I found the reliable sessions that WCF supports. I see that by using reliable sessions, there are two timers which one needs to take into consideration: the Binding.ReceiveTimeout and the ReliableSession.InactivityTimeout.

After searching on the internet, I am still unable to understand exactly how these two work together. I know that if either of the two times out, the connection goes into faulted state.

My first question: What exactly happens when reliable sessions are enable?

My second question: Here, why does msdn say the following?

Since the connection is dropped if either inactivity timer fires, increasing InactivityTimeout once it is greater than ReceiveTimeout has no effect. The default for both of these timeouts is 10 minutes, so you always have to increase both of them to make a difference when using a reliable session.


回答1:


To get an answer for your first question, have a look at the nice answer to this question:

What is the purpose of WCF reliable session?

To my the explanation on the msdn site is clear: When the time specified in ReceiveTimeout(for example 10 minutes) is reached, it will end the connection, even if the reliable session has a keep alive beeing sent (for example every 1 minute).

The keep alive beeing sent every minute would make sure the inactivityTimout (for example 5 minutes) is never reached -therefor the channel would be kept open endlessly-, but after the time speciefied in ReceiveTimeout the session/channel still will be closed.

So ReceiveTimeout should always be higher or the same as inactivityTimeout, as far as I understand.



来源:https://stackoverflow.com/questions/12872017/wcf-binding-receivetimeout-reliablesession-inactivitytimeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!