Cannot consume WCF service net.tcp protocol in Silverlight RRS feed

  • Question

  • Hi all,

    I am running to the trouble of consuming WCF net.tcp in silverlight. I have a project which create and host WCF to Windows Azure using net.tcp protocol. Now I want to consume this service with Silverlight client. However, I could not make it work.

    In my project, I create a web role in Windows Azure which will host WCF net.tcp protocol. In client site, I create Silverlight project using this service. When I make a call from Silverlight to this service (hosted in Windows Azure), I always get the error TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. This could be due to attempting to access a service in a cross-domain way while the service is not configured for cross-domain access.

    In the service config file, here is the configuration:

            <binding name="tcpBinding">
              <security mode="None"/>
          <service name="Service1">
            <endpoint address="net.tcp://testnettcp.cloudapp.net:4503/WebRole1/Service1.svc"
                      binding="netTcpBinding" bindingConfiguration="tcpBinding"
            <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />

    In the silverlight client site, here is the configuration:

            <binding name="TcpBinding">
              <binaryMessageEncoding />
              <tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"/>

                  <endpoint address="net.tcp://testnettcp.cloudapp.net:4503/Service/Service1.svc"
                   binding="customBinding" bindingConfiguration="TcpBinding"
                   contract="Service1.IService1" name="NetTcpBinding_Service1"/>

    In the OnStart() method of WebRole in Windows Azure, I also have a script to configure IIS of Windows Azure:

    public override bool OnStart()
                var startInfo = new ProcessStartInfo()
                    FileName = "powershell.exe",
                    Arguments = @".\setup\rolestart.ps1",
                    RedirectStandardOutput = true,
                    UseShellExecute = false,

                var writer = new StreamWriter("out.txt");

                var process = Process.Start(startInfo);

                return base.OnStart();

    where rolestart.ps1 is a PowerShell script as follow:

    write-host "Begin RoleStart.ps1"
    import-module WebAdministration

    # Starting the listener service
    $listenerService = Get-WmiObject win32_service -filter "name='NetTcpActivator'"
    $listenerService = Get-WmiObject win32_service -filter "name='NetTcpPortSharing'"

    # Enable net.pipe bindings
    $WebRoleSite = (Get-WebSite "*webrole*").Name
    Get-WebApplication -Site $WebRoleSite | Foreach-Object { $site = "IIS:/Sites/$WebRoleSite" + $_.path; Set-ItemProperty $site -Name EnabledProtocols 'http,net.tcp'}
    New-ItemProperty "IIS:/Sites/$WebRoleSite" -name bindings -value @{protocol="net.tcp";bindingInformation="808:*"}

    write-host "End RoleStart.ps1"

    These above steps I got from this site: http://blogs.msdn.com/b/windowsazure/archive/2011/06/27/hosting-services-with-was-and-iis-on-windows-azure.aspx

    Is there anyone can help take a look and advise me solving this issue?


    Tuesday, July 12, 2011 2:59 AM