Cannot connect to one of my WCF services, not even with telnet

Posted by Ecyrb on Stack Overflow See other posts from Stack Overflow or by Ecyrb
Published on 2010-04-06T20:30:02Z Indexed on 2010/04/06 20:33 UTC
Read the original article Hit count: 714

Filed under:
|
|

I have six wcf services that I'm hosting in a windows service. Everything works great on my machine (Windows 7) but when I try it in production (Windows Server 2003) I cannot connect to one of my six services, ReportsService.

I figured I must have a typo, but everything looks right. I've even rewritten that section of the config file just to be sure.

I've turned on WCF tracing, but it never shows the call to my service; nothing helpful in there.

I tried connecting to the port (9005) with telnet, but it failed. I can connect to all other services (ports 9001-4 and 9006) just fine.

I thought that maybe there was a problem with port 9005, so I changed it to 9007 and still couldn't connect. I had one of my working services host on 9005 and it actually worked fine. So I'm pretty sure there's nothing wrong with the port or any firewall settings. Whatever port I tell ReportsService to use fails.

Now I'm out of ideas. It seems like it's not hosting that one service, but I cannot get any information about why or what's wrong. Any ideas on what I could try to get that information? Or what might be wrong?

The unhandled System.ServiceModel.EndpointNotFoundException I get when running my client is:

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

My host's config file contains:

<!-- Snipped other services to simplify for you. -->
<endpoint binding="netTcpBinding" bindingConfiguration="customTcpBinding" contract="ServiceContracts.IReportsService" />
<endpoint binding="netTcpBinding" bindingConfiguration="customTcpBinding" contract="ServiceContracts.IUpdateData" />

IReportService is the one I'm having trouble with. I get a proxy to IReportsService with the following code, where Server is the name of the hosting machine:

return new ChannelFactory<IReportsService>("").CreateChannel(new EndpointAddress(string.Format("net.tcp://{0}:9005/ReportsService", Server)));

My client config file contains:

<system.serviceModel>
  <bindings>
    <netTcpBinding>
      <binding name="customTcpBinding" maxReceivedMessageSize="2147483647">
        <readerQuotas maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
        <security mode="None"/>
      </binding>
    </netTcpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior name="ServiceBehavior">
        <serviceMetadata httpGetEnabled="True"/>
        <serviceDebug includeExceptionDetailInFaults="True" />
        <serviceThrottling maxConcurrentCalls="30" maxConcurrentInstances="30" maxConcurrentSessions="1000" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <!-- Snipped other services to simplify for you. -->
    <service behaviorConfiguration="ServiceBehavior" name="WcfService.ReportsService">
      <endpoint address="ReportsService" binding="netTcpBinding" bindingConfiguration="customTcpBinding"
        contract="ServiceContracts.IReportsService" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:9005" />
        </baseAddresses>
      </host>
    </service>
    <service behaviorConfiguration="ServiceBehavior" name="WcfService.UpdateData">
      <endpoint address="UpdateData" binding="netTcpBinding" bindingConfiguration="customTcpBinding"
        contract="ServiceContracts.IUpdateData" />
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:9006" />
        </baseAddresses>
      </host>
    </service>
  </services>
</system.serviceModel>

I've tried to keep things simple with the code snippets above, but if you would like to see more just ask and I'd be happy to provide anything that'll help.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about wcfservice