【问题标题】:net.tcp binding with streamed transfer mode = Framing mode Singleton is not supportednet.tcp 与流传输模式绑定 = 不支持单例模式
【发布时间】:2011-03-30 18:36:28
【问题描述】:

我正在尝试在 WCF 方法中实现即发即弃模式。我在本地环境中有这个工作,但在 IIS7 上运行时遇到了问题。

我正在使用 net.tcp 绑定,并发现即使使用此绑定的单向调用,关闭代理也会阻塞 UI(在本例中为 asp.net 网站),直到操作完成。正如this article 中所建议的,我将传输模式更改为流式传输,以便关闭代理不会导致等待。

正如我所提到的,当我在 localhost 上运行时,这是有效的,但是当我部署到 IIS7 时,我一点击使用合同方法的页面就会收到此错误:

“不支持成帧模式单例。”

如果我将绑定的 transferMode 属性更改为 'Buffered',我不会收到错误消息,但我会回到原来的问题,即在服务之前关闭代理块操作完成

任何帮助将不胜感激。

我的代码:

// Operation Contract
[OperationContract(Name = "LoadNewDataset", IsOneWay = true)]
void LoadDataset(Workspace workspace, Connection connection, string dataSetName);

// WCF Config snippets:
<bindings>
  <netTcpBinding>
    <binding name="NetTcpStreamBinding" 
             transferMode="Streamed">
    </binding>
  </netTcpBinding>
</bindings>

....

<endpoint address="DataImportService" binding="netTcpBinding"
  bindingConfiguration="NetTcpStreamBinding" name="DataImportEndpoint"
  contract="MediaBrands.Adroit.WCF.IDataImportService" />


//Website web.config 
<bindings>
  <netTcpBinding>
    <binding name="DataImportEndpoint" closeTimeout="00:10:00" openTimeout="00:01:00"
      receiveTimeout="00:10:00" sendTimeout="00:10:00" transferMode="Streamed"
      hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
      maxBufferSize="5242880" maxReceivedMessageSize="5242880">
      <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
      </security>
    </binding>

....

    <endpoint address="net.tcp://localhost:8001/AdroitWcf/DataImportService"
      binding="netTcpBinding" bindingConfiguration="DataImportEndpoint"
      contract="AdroitServiceReference.IDataImportService" name="DataImportEndpoint">
    </endpoint>

【问题讨论】:

    标签: .net wcf iis-7 nettcpbinding


    【解决方案1】:

    这是因为您的安全模式是消息。连接需要等到 InstanceContext 完成后才能发送取消令牌以结束安全会话。

    尝试将安全模式设置为无或传输(取决于您的需要)。或者,您可以使用如下所示的代码将代理传递给 ThreadPool.QueueUserWorkItem(ShutItDown, proxy):

    void ShutItDown(对象数据){ var proxy = (ProxyType) 数据; 代理.关闭(); }

    【讨论】:

    • 安全模式是传输,而不是消息
    • 按照此处的建议将其传递给另一个线程以关闭代理似乎是一种有效的解决方法。标记为已接受的答案,谢谢!
    猜你喜欢
    • 1970-01-01
    • 2010-11-30
    • 1970-01-01
    • 2011-05-01
    • 2018-07-22
    • 2013-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多