最终WCF双工Silverlight 4客户端开始获取404 Not Found轮询消息的错误,在轮询从WCF服务发送到Silverlight客户端之后立即发生,有时这种情况发生在第二次轮询中,有时连接工作数小时甚至数天,但大多数在第一分钟失败.
!有趣的是,这个问题就像使用MaxMessagesPerPoll双工模式时已知的Silverlight 4错误一样,这里和这里描述了解决方案,但我正在使用SingleMessagePerPoll模式.ANyway我ClientStack按照建议尝试使用,但没有任何改变.
一般流程:
System.Net.WebException:远程服务器返回错误:NotFound
404轮询消息的空响应我试图在出现这样的故障后重新连接SL客户端,单个重新连接重试流程:
Faulted事件Closed/Closing/Opened/Openingtry { close } catch { abort }DuplexChannelFactory<T>实例创建新通道,仅为了记录目的订阅所有通道事件1-10次重试(~1-10分钟)后,客户端最终连接到服务器并继续正常轮询.
在WCF服务日志中,我看到它获得了所有cleint请求,没有任何异常处理,因此似乎Silverlight客户端发生了一些事情.
我使用HTTP轮询双工WCF通道跟踪了Tomek Janczuk的Pub/sub示例,但我注意到当客户端通过关闭浏览器而断开连接时,服务在下一次回调时没有注意到.我原本应该预料到一个例外,或者说某个端点不再存在.
你怎么知道客户何时离开,以便停止向该客户发布?
我已经在Silverlight 4应用程序中实现了轮询双工,以便使用来自服务器的客户端回调获取大量数据,因此我的服务包含一些带有客户端回调的功能和一些没有回调的功能.当只有3或4个函数被称为并行时,它工作正常,当有超过5或6个并行调用时,我得到ServerTooBusyException(服务太忙).
设置serviceThrottling maxConcurrentCalls ="10000"maxConcurrentInstances ="10000"maxConcurrentSessions ="10000"值后,我无法解决问题.
当我将basichttpbinding应用于服务时,一切正常,但是当pollingDuplexHttpBinding应用时,它给出了错误
我跟随Tomek Janczuk在silverlight tv上的演示,创建了一个使用WCF Duplex Polling Web服务的聊天程序.客户端订阅服务器,然后服务器向所有连接的客户端发起通知以发布事件.
想法很简单,在客户端上,有一个允许客户端连接的按钮.客户端可以编写消息并将其发布的文本框,以及显示从服务器接收的所有通知的更大文本框.
我连接了3个客户端(在不同的浏览器中 - IE,Firefox和Chrome),它们都运行良好.他们发送消息并顺利接收.当我关闭其中一个浏览器时,问题就出现了.一个客户一出门,其他客户就会卡住.他们停止收到通知.
我猜测服务器中通过所有客户端并向他们发送通知的循环卡在现在丢失的客户端上.我尝试捕获异常并将其从客户端列表中删除(请参阅代码)但它仍然没有帮助.
有任何想法吗?
服务器代码如下:
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Runtime.Remoting.Channels;
namespace ChatDemo.Web
{
[ServiceContract]
public interface IChatNotification
{
// this will be used as a callback method, therefore it must be one way
[OperationContract(IsOneWay=true)]
void Notify(string message);
[OperationContract(IsOneWay = true)]
void Subscribed();
}
// define this as a callback contract - to allow push
[ServiceContract(Namespace="", CallbackContract=typeof(IChatNotification))]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class ChatService …Run Code Online (Sandbox Code Playgroud) 我有WCF服务.这是配置
<basicHttpBinding>
<binding name="EmergencyRegistratorBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)
和服务配置
<service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="EmergencyRegistratorBinding"
contract="Services.IEmergencyRegistrator" />
</service>
Run Code Online (Sandbox Code Playgroud)
一切都很好.但我需要将basicHttpBingind更改为DuplexBinding.我添加了延伸:
<extensions>
<bindingElementExtensions>
<add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex"/>
</bindingElementExtensions>
</extensions>
Run Code Online (Sandbox Code Playgroud)
并改变上面提到的行:
<customBinding>
<binding name="DuplexmergencyRegistratorBinding">
<binaryMessageEncoding/>
<pollingDuplex maxPendingSessions="2147483647" maxPendingMessagesPerSession="2147483647" inactivityTimeout="02:00:00" serverPollTimeout="00:05:00"/>
<httpTransport authenticationScheme="Negotiate"/>
</binding>
</customBinding>
Run Code Online (Sandbox Code Playgroud)
和
<service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
<endpoint address="" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="Breeze.Core.Services.IEmergencyRegistrator" />
<endpoint address="mex" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="IMetadataExchange"/>
</service>
Run Code Online (Sandbox Code Playgroud)
我已将服务参考添加到WCF项目.引用已成功添加,但Reference.cs几乎为空.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.225
//
// Changes …Run Code Online (Sandbox Code Playgroud)