net.tcp binding with streamed transfer mode = Framing mode Singleton is not supported

此生再无相见时 提交于 2019-12-11 07:43:57

问题


I'm trying to implement a fire-and-forget pattern in a WCF method. I have this working in my local environment, but running into an issue when running on IIS7.

I'm using net.tcp binding, and discovered that even when using a one-way call with this binding, closing the proxy will block the UI (in this case an asp.net website) until the operation completes. I changed the transfer mode to streamed so that closing the proxy will not cause a wait, as suggested in this article.

As I mentioned, this is working when I run on localhost, but when I deploy to IIS7, I'm getting this error as soon as i hit the page which utilizes the contract method:

"Framing mode Singleton is not supported."

If I change the binding's transferMode attribute to 'Buffered', I don't get the error, but I'm back to my original problem of having closing the proxy block until the service operation completes

Any help would be greatly appreciated.

My Code:

// 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>

回答1:


This is because your security mode is Message. The connection needs to wait until the InstanceContext is done to send the cancellation token to end the secure session.

Try setting the security mode to None or Transport (depending on your needs). Alternatively, you can pass the proxy to ThreadPool.QueueUserWorkItem(ShutItDown, proxy) with some code that looks something like this:

void ShutItDown(object data){ var proxy = (ProxyType) data; proxy.Close(); }



来源:https://stackoverflow.com/questions/5490627/net-tcp-binding-with-streamed-transfer-mode-framing-mode-singleton-is-not-supp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!