Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure a Windows Azure WCF Service Web Role to work with netTcpBinding?

I have a WCF Service hosted on Windows Azure and I just recently changed it's contract to be a Duplex contract (to support a progress bar on the client). I first used the wsDualHttpBinding which worked well on my local machine, but as expected failed to work once I deployed it.

I am now trying to configure the service to work with netTcpBinding, but I'm getting the error "The protocol specified is not valid. The protocol 'tcp' for the binding named 'Endpoint1' is currently not supported.".

ServiceDefinition.csdef :

<Endpoints>
  <InputEndpoint name="AlertsEndpoint" protocol="tcp" port="3030" />
</Endpoints>

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>      
like image 949
Lescai Ionel Avatar asked Feb 27 '12 10:02

Lescai Ionel


3 Answers

Web Roles hosting WCF services doesn't support the TCP protocol. You will need to host your WCF service in a Worker Role.

Web Roles:

Web roles in Windows Azure provide support for the HTTP and HTTPS protocols...

Worker Roles:

...and allow the process to communicate externally using a variety of TCP-based application protocols with the WCF service by using the netTcpBindings binding

like image 98
Magnus Johansson Avatar answered Nov 07 '22 10:11

Magnus Johansson


You can enable whatever bindings you like for WCF on Azure in a web role by running startup scripts to enable say net.tcp (after all its just IIS at the end of the day, although I admit its more of a pain than it should be!). Full details can be seen at this article

like image 2
Mike Hanrahan Avatar answered Nov 07 '22 09:11

Mike Hanrahan


Let me clarify this, as the answer given by @magnus johansson is not entirely correct. Web Roles in Windows Azure most certainly do support tcp. However: Hosting WCF services in IIS are limited to HTTP only. If you choose to instantiate your own ServiceHost outside of IIS, then you'll have no problem with tcp.

Here's an MSDN article describing WCF hosting in IIS, in more detail.

like image 1
David Makogon Avatar answered Nov 07 '22 09:11

David Makogon