Do I need to Close and/or Dispose callback channels acquired through OperationContext.Current.GetCallbackChannel?

后端 未结 2 1940
一整个雨季
一整个雨季 2021-02-13 10:21

I\'m using OperationContext.Current.GetCallbackChannel to get a channel to the client that called a WCF service operation.

Do I need to worry about closing / disposing

2条回答
  •  醉酒成梦
    2021-02-13 10:40

    Well, I just tried it myself and it turns out that if you Close & Dispose the callback channel (after casting to IClientChannel) the entire Service channel becomes useless and when called throws a ProtocolException saying:

    "This channel can no longer be used to send messages as the output session was auto-closed due to a server-initiated shutdown. Either disable auto-close by setting the DispatchRuntime.AutomaticInputSessionShutdown to false, or consider modifying the shutdown protocol with the remote server."

    I assume that this is an unwelcome consequence or side effect of attempting to close & dispose the callback channel, meaning that this should not be done.

提交回复
热议问题