加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – WCF Streaming:仅在net.tcp中出现帧模式错误

发布时间:2020-12-15 22:00:00 所属栏目:百科 来源:网络整理
导读:我有一个应用程序服务器使用默认的transferMode =“Buffered”和一个Streamed服务实现一堆服务.它公开了basicHttp和net.tcp协议的端点,并在几十个IIS 7.0配置下运行,没有发生任何事故. 当我为新应用程序的服务器复制架构时,net.tcp上的流式传输只是拒绝工作,
我有一个应用程序服务器使用默认的transferMode =“Buffered”和一个Streamed服务实现一堆服务.它公开了basicHttp和net.tcp协议的端点,并在几十个IIS 7.0配置下运行,没有发生任何事故.

当我为新应用程序的服务器复制架构时,net.tcp上的流式传输只是拒绝工作,抛出完全不透明和钝的ProtocolException

The .Net Framing mode being used is not supported by MyNetTcpEndpointAddress. See the server logs for more details.

是的,“服务器日志”. (没有任何内容,无论是否跟踪.)S1和S2的服务架构和web.config是相同的,除了

>一些名称更改
> S2中的自定义命名空间(S1使用tempuri)
>不同的端口(S1和S2均使用8000-9000范围内的端口)

流式服务S2在basicHttp下运行正常.

尝试了所有内容并且未能使错误消失后,我构建了一个测试客户端,除了使用一些Ping方法运行我的服务架构之外什么都不做. ChannelFactory代理周围没有自定义命名空间,没有多余的装饰,只有原始配置,精简服务,合同和手工编码的包装器.

同样的错误:

The .Net Framing mode being used is not supported by ‘net.tcp://localhost:9931/StreamingService.svc’. See the server logs for more details.

缓冲测试服务在两种协议下工作,流服务在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失败.以下是该运行的完整输出:

C:Program Files (x86)Microsoft SDKsWindowsv7.0ABin>svcutil
net.tcp://localhost:9931/StreamingService.svc Microsoft (R) Service
Model Metadata Tool [Microsoft (R) Windows (R) Communication
Foundation,Version 3.0.4506.2152] Copyright (c) Microsoft
Corporation. All rights reserved.

Attempting to download metadata from
‘net.tcp://localhost:9931/StreamingService.svc’ using WS-Metadata
Exchange. This UR L does not support DISCO. Microsoft (R) Service
Model Metadata Tool [Microsoft (R) Windows (R) Communication
Foundation,Version 3.0.4506.2152] Copyright (c) Microsoft
Corporation. All rights reserved.

Error: Cannot obtain Metadata from
net.tcp://localhost:9931/StreamingService.svc

If this is a Windows (R) Communication Foundation service to which you
have access,please check that you have enabled m etadata publishing
at the specified address. For help enabling metadata publishing,
please refer to the MSDN documentat ion at
07001.

WS-Metadata Exchange Error
URI: net.tcp://localhost:9931/StreamingService.svc

Metadata contains a reference that cannot be resolved: ‘net.tcp://localhost:9931/StreamingService.svc’.

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout bei ng exceeded by
the remote host,or an underlying network resource issue. Local socket
timeout was ’00:04:59.9929993′.

An existing connection was forcibly closed by the remote host

If you would like more help,type “svcutil /?”

其次,从上面粘贴的Wcf.Bindings.Streaming.Tcp web和app配置中删除“transferMode =”Streamed“允许服务ping正常.它不会改善svcutil情况.

最后,这里有一些我尝试过的其他事情,没有任何改进:

> serviceBehaviors中的各种版本的serviceMetadata属性(我知道无论如何都会被mex端点的存在所覆盖)
>各种命名的serviceBehaviors而不是默认的I include
>安全模式的各种配置=关于绑定,尤其是无
>所有其他绑定,端点等的各种异常,希望有一件事可能会以另一种方式进入

解决方法

似乎在服务端或客户端传输tcp通信的transferMode到Streamed,而另一端仍然使用Buffered的默认模式.

在TCP的情况下,您是否忘记了“StreamingProxy”中的内容?

可能这会有所帮助……
http://social.msdn.microsoft.com/Forums/vstudio/en-US/37e32166-63f3-4cb9-ab81-14caa50cd91e/help-with-error-message-the-net-framing-mode-being-used-is-not-supported-by-?forum=wcf

此外,我正在尝试进一步寻找您的解决方案……

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读