如何配置Windows Azure WCF服务Web角色以使用netTcpBinding?

Les*_*nel 5 .net c# windows wcf azure

我在Windows Azure上托管了WCF服务,最近我将其合同更改为双工合同(以支持客户端上的进度条).我首先使用wsDualHttpBinding,它在我的本地机器上运行良好,但是一旦我部署它就像预期的那样无法工作.

我现在正在尝试配置服务以使用netTcpBinding,但我收到错误"指定的协议无效.目前不支持名为'Endpoint1'的绑定的协议'tcp'."

ServiceDefinition.csdef:

<Endpoints>
  <InputEndpoint name="AlertsEndpoint" protocol="tcp" port="3030" />
</Endpoints>
Run Code Online (Sandbox Code Playgroud)

Web.config文件:

 <services>      
      <service name="AlertsService.AlertsService" behaviorConfiguration="AlertsServiceBehavior">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcp" contract="AlertsService.IAlertsService" />
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="MexTcp" contract="IMetadataExchange" />
      </service>
    </services>  

<bindings>
      <netTcpBinding>
        <binding name="NetTcp" />
      </netTcpBinding>
      <mexTcpBinding>
        <binding name="MexTcp"/>
      </mexTcpBinding>
</bindings>      
Run Code Online (Sandbox Code Playgroud)

Mag*_*son 4

Web Roles托管 WCF 服务不支持 TCP 协议。您需要将 WCF 服务托管在Worker Role.

网络角色:

Windows Azure 中的 Web 角色提供对 HTTP 和 HTTPS 协议的支持...

工人角色:

...并允许进程使用各种基于 TCP 的应用程序协议通过使用 netTcpBindings 绑定与 WCF 服务进行外部通信

  • 不完全正确 - Web 角色*确实*支持 TCP。IIS 托管的 WCF 服务则不然。 (3认同)