Handling dropped clients in a duplex binding WCF application

后端 未结 2 1437
迷失自我
迷失自我 2020-12-14 03:31

We are using a pub-sub model in our WCF application that pretty much follows the Microsoft sample: Design Patterns: List-Based Publish-Subscribe.

Whilst the service

相关标签:
2条回答
  • 2020-12-14 04:12

    I did some testing where I attached handlers to the Closed and Faulted events of the callback channel, then killed the client at the point just before the callback would be invoked by the server. On each trial, the Closed/Faulted event was fired instantaneously and before the server attempted to invoke the callback. All the same, I still have the callback invocation wrapped in a try-catch block because the destruction of the client channel could occur just as another thread was entering the callback.

    The only clean-up necessary was to remove the reference to the callback channel. WCF and the garbage-collector do the rest.

    0 讨论(0)
  • 2020-12-14 04:18

    Handling those events will keep your list of subscribers synchronized. It is indeed robust enough. Just remember that if a client drops during a transmission of a message, you might get an exception before those events fire, so be ready to ignore them so that the events can clean up.

    Except for removing the client from he subscribers list, additional cleanup depends entirely on your application (i.e. freeing resources you acquired when the client connected). I am not aware of any other cleanup that is required.

    0 讨论(0)
提交回复
热议问题