使用的net.tcp流传输模式结合=帧模式辛格尔顿不支持模式、不支持、格尔、net

由网友(蓝色天空)分享简介:我想实现一个发射后忘记一个WCF方法模式。我有这个工作在我的本地环境中,但在IIS7运行时,运行到一个问题。我使用net.tcp绑定,并发现使用单向通话与此结合,即使,关闭代理将阻止用户界面(在这种情况下,一个asp.net网站)直到操作完成。我改变了传递方式来流,使关闭代理不会造成等待,在这篇文章。正如我所说,这是当...

我想实现一个发射后忘记一个WCF方法模式。我有这个工作在我的本地环境中,但在IIS7运行时,运行到一个问题。

我使用net.tcp绑定,并发现使用单向通话与此结合,即使,关闭代理将阻止用户界面(在这种情况下,一个asp.net网站)直到操作完成。我改变了传递方式来流,使关闭代理不会造成等待,在这篇文章。

正如我所说,这是当我运行在本地主机的工作,但是当我部署到IIS7,我得到这个错误,只要我打它利用合同法的页面:

  

不支持取景模式单身。

如果我更改绑定的 transferMode 属性的缓冲的,我没有得到的错误,但我回到我的具有关代理块,直到该服务操作完成的原始问题

任何帮助将是很大的AP preciated。

我的code:

  //经营合同
[OperationContract的(名称=LoadNewDataset,IsOneWay =真)
无效LoadDataset(工作区工作区,连接接口,串数据集名称);

// WCF配置片段:
<绑定>
  < NetTcpBinding的>
    <绑定名称=NetTcpStreamBinding
             transferMode =流媒体>
    < /装订>
  < / NetTcpBinding的>
< /绑定>

....

<端点地址=DataImportService绑定=NetTcpBinding的
  bindingConfiguration =NetTcpStreamBindingNAME =DataImportEndpoint
  合同=MediaBrands.Adroit.WCF.IDataImportService/>


//网站的web.config
<绑定>
  < NetTcpBinding的>
    <绑定名称=DataImportEndpointcloseTimeout =00:10:00openTimeout =00:01:00
      receiveTimeout =00:10:00的SendTimeout =00:10:00transferMode =流媒体
      hostNameComparisonMode =StrongWildcardmaxBufferPoolSize =524288
      maxBufferSize =5242880maxReceivedMessageSize =5242880>
      < readerQuotas MAXDEPTH =32maxStringContentLength =65536maxArrayLength =16384
        maxBytesPerRead =4096maxNameTableCharCount =16384/>
      <安全模式=运输>
        <交通运输clientCredentialType =窗口的ProtectionLevel =EncryptAndSign/>
      < /安全>
    < /装订>

....

    <端点地址=的net.tcp://本地主机:8001 / AdroitWcf / DataImportService
      绑定=NetTcpBinding的bindingConfiguration =DataImportEndpoint
      合同=AdroitServiceReference.IDataImportServiceNAME =DataImportEndpoint>
    < /端点>
 

解决方案 基于 Socket 的 UDP 和 TCP 编程介绍

这是因为您的安全模式的消息。连接需要等到的InstanceContext做是为了发送取消标记结束安全会话

尝试安全模式设置为无或交通运输(根据您的需要)。另外,您也可以通过代理来ThreadPool.QueueUserWorkItem(ShutItDown,代理)有一些code,它看起来是这样的:

无效ShutItDown(对象数据){   VAR代理=(的proxyType)的数据;   proxy.Close(); }

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>

解决方案

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(); }

阅读全文

相关推荐

最新文章