2
votes

I tried to setup a service for testing using a net.tcp binding. I also set a http endpoint. The configuration is as follows:

  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="Inbound_REST">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="InboundHttpConfiguration">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="InboundTcpConfiguration">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="InboundTcpConfiguration" name="Inbound">
          <endpoint address="" binding="netTcpBinding" contract="IContract">
            <identity>
              <dns value="localhost"/>
            </identity>
          </endpoint>
          <host>
            <baseAddresses>
              <add baseAddress="net.tcp://localhost:6969/Inbound" />
            </baseAddresses>
          </host>
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <client>
      <endpoint name="httpEndPoint" address="http://localhost:1568/Inbound.svc" binding="basicHttpBinding" contract="IContract" />
       <endpoint name="tcpEndPoint" address="net.tcp://localhost:6969/Inbound" binding="netTcpBinding" contract="IContract" />
    </client>
    <bindings>
      <basicHttpBinding>
        <binding name="httpbind">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding name="tcpbind">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
  </system.serviceModel>

When I attempt to consume the service using the net.tcp binding, it always return me the error:

Could not connect to net.tcp://localhost:6969/Inbound. The connection attempt lasted for a time span of 00:00:00.9531494. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:6969.

By the way, the http binding works fine. I think it could be some machine configuration, but wasn't able to find what's the root cause.

3
How are you hosting your service? WAS? A windows service?Tad Donaghe

3 Answers

3
votes

If you are trying to run your WCF service through visual studio netTcpBinding is not supported. Sorry!

Check out this post for a more detailed explanation.

0
votes

Why did you leave out the ".svc" for the net.tcp address for the client? Maybe it should be "net.tcp://localhost:6969/Inbound.svc"

0
votes

What hosting you are using..IIS7 or console or others?

1)Check all tcp services are running in services.msc

2)Turn off your fire wall or add firewall exception to your tcp port

if you are hosting in iis7 check this link

IIS7 support for non http protocols