开发者

WCF - Closing a duplex ServiceHost blocks for CloseTimeout duration if closed when client(s) connected

I have a Windows Service that hosts three different duplex WCF channe开发者_开发技巧ls. Clients can connect to have updates sent to them via their callback contract. Essentially there are three pub-sub channels.

This service takes a long time to bounce when clients are connected. The call to ServiceHost.Close takes 10 seconds to return (so the service takes 30+ seconds to stop.) It turns out that my closeTimeout in config is 10 seconds. Changing this value indicates that this is the cause of the problem.

What do I have to do to close the channel promptly? I don't like the idea that something is timing out. I could call Abort, but it seems that there must be a better way. I haven't seen this on non-duplex channels before, so assume it's something to do with it being duplex.

Ideally the client would be notified immediately that the channel had faulted, so that the user could see straight away that updates have halted.


"Ideally the client would be notified immediately that the channel had faulted, so that the user could see straight away that updates have halted."

The WCF client instance has events you can subscribe to:

  • Closed
  • Closing
  • Faulted
  • Opened
  • Opening.

The Faulted event is raised as soon as your duplex channel halted from any reason.

I wonder why is your is your service host taking 30+ seconds to close. Can you provide some sample code?


Probably, the best way is to notify client (you have duplex, so you can) and let client close the channel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜