4

I have a Silverlight 4.0 application using nettcp working in HTTP. I then attempted to switch from http to https. This is where I started to run into issues. When I run the application I receive an Internet Explorer notification "Display Mixed Content?". If I click "Yes" then I receive an error in my application:

Could not connect to net.tcp://ServerName:4502/TestService.svc/netTcp. The connection attempt lasted for a time span of 00:00:01.2191219. TCP error code 10013: An attempt was made to access a socket in a way forbidden by its access permissions.. 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. You may need to contact the owner of the service to expose a sockets cross-domain policy over HTTP and host the service in the allowed sockets port range 4502-4534.

My ClientConfig is as follows:

    <configuration>
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="NetTcpBinding_ITestService">
          <binaryMessageEncoding />
          <tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://ServerName:4502/TestService.svc/netTcp"
        binding="customBinding" bindingConfiguration="NetTcpBinding_ITestService"
        contract="TestServer.ITestService" name="NetTcpBinding_ITestService"/>
    </client>
  </system.serviceModel>
</configuration>
 

My Web.config is as follows:

 <netTcpBinding>
      <binding name="netTcpBindingConfig">
        <security mode="None" />
      </binding>
    </netTcpBinding>

  </bindings>
  <services>
    <service name="TestService">
      <endpoint address="netTcp" binding="netTcpBinding" bindingConfiguration="netTcpBindingConfig" contract="ITestService" />
      <endpoint address="mex" binding="mexHttpsBinding" name="mex" contract="IMetadataExchange" />
      <host>
      <baseAddresses>
        <add baseAddress="net.tcp://ServerName:4502/TestService.svc" />
        <add baseAddress="https://ServerName/TestService.svc" />
      </baseAddresses>
      </host>
    </service>
  </services>
     

At the Root of my server I have a file called clientaccesspolicy.xml:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
          <domain uri="http://*"/>
          <domain uri="https://*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true" />
        <socket-resource port="4502-4530" protocol="tcp" />
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

The nettcp communication does not need to be secure, but other services in the application require security. Is it possible to get nettcp running in an HTTPS hosted application?

Anonymous
  • 738
  • 4
  • 14
  • 36
Ryan
  • 41
  • 2

0 Answers0