c# – WCF Streaming:仅在net.tcp中出现帧模式错误
我有一个应用程序服务器使用默认的transferMode =“Buffered”和一个Streamed服务实现一堆服务.它公开了basicHttp和net.tcp协议的端点,并在几十个IIS 7.0配置下运行,没有发生任何事故.
当我为新应用程序的服务器复制架构时,net.tcp上的流式传输只是拒绝工作,抛出完全不透明和钝的ProtocolException
是的,“服务器日志”. (没有任何内容,无论是否跟踪.)S1和S2的服务架构和web.config是相同的,除了 >一些名称更改 流式服务S2在basicHttp下运行正常. 尝试了所有内容并且未能使错误消失后,我构建了一个测试客户端,除了使用一些Ping方法运行我的服务架构之外什么都不做. ChannelFactory代理周围没有自定义命名空间,没有多余的装饰,只有原始配置,精简服务,合同和手工编码的包装器. 同样的错误:
缓冲测试服务在两种协议下工作,流服务在basicHttp下工作,如S2. 所有测试都在具有完整IIS设置的同一台Win7机器上完成.测试应用程序仍然太大,无法在此发布,但这里是完整的配置和控制台代码 web.config中 <configuration> <connectionStrings> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0" /> <!-- throttling of stream size is partially controlled by this setting --> <httpRuntime maxRequestLength="1048576" /><!-- 1GB --> </system.web> <system.serviceModel> <serviceHostingEnvironment> <serviceActivations> <add relativeAddress="FooService.svc" service="WcfTest.Services.FooService" /> <add relativeAddress="StreamingService.svc" service="WcfTest.Services.StreamingService" /> </serviceActivations> </serviceHostingEnvironment> <behaviors> <serviceBehaviors> <behavior> <dataContractSerializer maxItemsInObjectGraph="200000" /> <serviceMetadata httpGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding openTimeout="00:20:00" sendTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"> <readerQuotas maxStringContentLength="12000" /> </binding> <binding name="WcfTest.Streaming.Http" transferMode="Streamed" openTimeout="03:00:00" sendTimeout="03:00:00" receiveTimeout="03:00:00" closeTimeout="03:00:00" maxReceivedMessageSize="1073741824" /><!-- 1GB --> </basicHttpBinding> <netTcpBinding> <binding openTimeout="00:20:00" sendTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"> <readerQuotas maxStringContentLength="12000" /> </binding> <binding name="WcfTest.Streaming.Tcp" transferMode="Streamed" openTimeout="03:00:00" sendTimeout="03:00:00" receiveTimeout="03:00:00" closeTimeout="03:00:00" maxReceivedMessageSize="1073741824"><!-- 1GB --> </binding> </netTcpBinding> </bindings> <protocolMapping> <add scheme="http" binding="basicHttpBinding" /> <add scheme="net.tcp" binding="netTcpBinding"/> </protocolMapping> <services> <service name="WcfTest.Services.Streaming"> <!-- http --> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="WcfTest.Streaming.Http" contract="WcfTest.Contracts.IStreamingService" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <!-- net.tcp --> <endpoint address="" binding="netTcpBinding" bindingConfiguration="WcfTest.Streaming.Tcp" contract="WcfTest.Contracts.IStreamingService" /> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> </service> </services> </system.serviceModel> </configuration> 的app.config <configuration> <system.serviceModel> <behaviors> <endpointBehaviors> <behavior> <dataContractSerializer maxItemsInObjectGraph="200000"/> </behavior> <behavior name="customQuotaBehavior"> <dataContractSerializer maxItemsInObjectGraph="2147483646"/> </behavior> </endpointBehaviors> </behaviors> <bindings> <basicHttpBinding> <binding openTimeout="00:20:00" sendTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"> <readerQuotas maxStringContentLength="12000" /> </binding> <binding name="WcfTest.Bindings.Streaming.Http" transferMode="Streamed" openTimeout="03:00:00" sendTimeout="03:00:00" receiveTimeout="03:00:00" closeTimeout="03:00:00" maxReceivedMessageSize="1073741824"><!-- 1GB --> </binding> </basicHttpBinding> <netTcpBinding> <binding openTimeout="00:20:00" sendTimeout="00:20:00" receiveTimeout="00:20:00" closeTimeout="00:20:00" maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"> <readerQuotas maxStringContentLength="12000" /> </binding> <binding name="WcfTest.Bindings.Streaming.Tcp" transferMode="Streamed" openTimeout="03:00:00" sendTimeout="03:00:00" receiveTimeout="03:00:00" closeTimeout="03:00:00" maxReceivedMessageSize="1073741824"><!-- 1GB --> </binding> </netTcpBinding> </bindings> <client> <!-- Foo --> <endpoint name="WcfTest.Endpoints.Foo.Http" address="http://localhost:9930/FooService.svc" binding="basicHttpBinding" contract="WcfTest.Contracts.IFooService" /> <endpoint name="WcfTest.Endpoints.Foo.Tcp" address="net.tcp://localhost:9931/FooService.svc" binding="netTcpBinding" contract="WcfTest.Contracts.IFooService" /> <!-- Streaming --> <endpoint name="WcfTest.Endpoints.Streaming.Http" address="http://localhost:9930/StreamingService.svc" binding="basicHttpBinding" bindingConfiguration="WcfTest.Bindings.Streaming.Http" contract="WcfTest.Contracts.IStreamingService" /> <endpoint name="WcfTest.Endpoints.Streaming.Tcp" address="net.tcp://localhost:9931/StreamingService.svc" binding="netTcpBinding" bindingConfiguration="WcfTest.Bindings.Streaming.Tcp" contract="WcfTest.Contracts.IStreamingService" /> </client> </system.serviceModel> </configuration> 控制台测试电话 static void Main(string[] args) { Console.WriteLine("starting WcfTest client..."); Console.WriteLine(); PingFoo(Contracts.Enums.Protocol.Http); PingFoo(Contracts.Enums.Protocol.Tcp); Console.WriteLine(); PingStreaming(Contracts.Enums.Protocol.Http); // only this call errors: PingStreaming(Contracts.Enums.Protocol.Tcp); Console.WriteLine(); Console.Write("ENTER to exit WcfTest client..."); Console.ReadLine(); } private static bool PingFoo(Contracts.Enums.Protocol protocol) { FooProxy pxy = new FooProxy(protocol); return PingProxy<IFooService>(pxy,protocol); } private static bool PingStreaming(Contracts.Enums.Protocol protocol) { StreamingProxy pxy = new StreamingProxy(protocol); return PingProxy<IStreamingService>(pxy,protocol); } private static bool PingProxy<T>(ProxyServiceBase<T> pxy,Contracts.Enums.Protocol protocol) where T : IServiceBase { bool success = pxy.Ping(); Console.WriteLine("ping {0} {1}: {2}",pxy.GetType().Name,protocol,success ? " success" : " FAILED"); if (pxy != null) pxy.Close(); return success; } 任何想法为什么这将在一个IIS站点上,在两个协议之一,而不是在另一个上失败? (它不是this.) 编辑:准备采取这个赏金方面,对这个测试服务和客户的几个澄清: 首先,根据评论者的建议,svcutil对http工作正常,但对net.tcp失败.以下是该运行的完整输出:
其次,从上面粘贴的Wcf.Bindings.Streaming.Tcp web和app配置中删除“transferMode =”Streamed“允许服务ping正常.它不会改善svcutil情况. 最后,这里有一些我尝试过的其他事情,没有任何改进: > serviceBehaviors中的各种版本的serviceMetadata属性(我知道无论如何都会被mex端点的存在所覆盖) 解决方法
似乎在服务端或客户端传输tcp通信的transferMode到Streamed,而另一端仍然使用Buffered的默认模式.
在TCP的情况下,您是否忘记了“StreamingProxy”中的内容? 可能这会有所帮助…… 此外,我正在尝试进一步寻找您的解决方案…… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |