再次更新赏金,因为我真的需要知道如何让它发挥作用,或者明确回答为什么它不会。
让双向 (IsOneWay = false) WCF 客户端-服务器在 .Net 3/3.5 中工作真是费尽心思。
客户端成功注册服务后,服务的周期性 Announcement() 回调注册的客户端。现在是客户端或服务器挂起,直到服务器的 SendTimeout(调整为 2 秒)过去。那么服务器端出现超时异常如下。只有这样,客户端用户代码才会立即接收方法调用并尝试返回一个值。到那时,客户端的套接字被中止并且 WCF 的东西失败了。
在我看来,客户端上的某些东西正在将其本地 WCF 队列从处理中挂起,直到套接字超时,但还不足以取消本地方法调用。但是,如果可以相信以下异常,则服务器正在尝试将操作发送到http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous(不合适!)并且正在超时。也许该 URI 只是远程连接客户端的“名称”,因为 WCF 知道出于错误消息的目的引用它,它似乎只是意味着它无法加载 URI。我不知道是服务器先失败还是客户端先失败。
我已经尝试添加 WCF 跟踪,但我没有获得更多信息。
类似的示例代码是here,但它一定是太多无法消化。我已经尝试过该代码的变体。
TimeoutException 'This request operation sent to http://schemas.microsoft.com/2005/12/ServiceModel/Addressing/Anonymous did not receive a reply within the configured timeout (00:00:00). The time allotted to this operation may have been a portion of a longer timeout. This may be because the service is still processing the operation or because the service was unable to send a reply message. Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client.'
Server stack trace:
at System.ServiceModel.Dispatcher.DuplexChannelBinder.SyncDuplexRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)