views:

245

answers:

2

I have six wcf services that I'm hosting in a windows service. Everything works great on my machine (Windows 7) (Edit: when hosted in Cassini, but not when running through the windows service) 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 127.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.

A: 

Try using the explicit IP of your box instead of "localhost" throughout your configs. "No connection could be made because the target machine actively refused it 172.0.0.1:9005". 172.0.0.1 looks like a wierd one... Just a guess. Also you might want to check who is listening on what port by running "netstat" on the command line.

Alex
Oops, "172.0.0.1:9005" was a typo. Should have been "127.0.0.1:9005". I've edited the question. And I did try netstat, per vittore's suggestion. Results are in the comments below the question. It looks like `ReportsService` is not being hosted, based on the netstat results, but I still don't know how to figure out why. My logs and traces aren't giving me any hints.
Ecyrb
Did you configure the trace to be "Verbose"? What did the trace roughly contain? I guess it is not completely empty. Also you can enable the network trace which might show you if your client is trying to open any sockets etc.
Alex
I used the recommended settings for debugging found at http://msdn.microsoft.com/en-us/library/aa702726%28v=VS.90%29.aspx. I then set the switchValue for all three sources to All. If I check the svclog right after starting my windows service I can see that it constructs, opens, and listens for all of my wcf services, except for `ReportsService`. There is absolutely nothing in the svclog mentioning `ReportsService`.
Ecyrb
A: 

I'm an idiot. I forgot to create and open a ServiceHost for the ReportsService in my windows service.... I thought everything worked fine on my machine, but really it only worked when hosted in Cassini, not when I actually installed the windows service on my machine. That's what finally tipped me off.

Thanks for the suggestions and for trying to help!

Ecyrb