4

I've developed a self-hosted WCF service using basicHttpBinding, and all works fine when the client is on the local machine. But when I try and connect from any machine on the network, it just times out, giving me the following error:

There was an error downloading 'http://192.168.0.59:8888/DannyService?wsdl'.
Unable to connect to the remote server
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 192.168.0.59:8888
Metadata contains a reference that cannot be resolved: 'http://192.168.0.59:8888/DannyService?wsdl'.
Could not connect to http://192.168.0.59:8888/DannyService?wsdl. 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 192.168.0.59:8888. 
Unable to connect to the remote server
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 192.168.0.59:8888
If the service is defined in the current solution, try building the solution and adding the service reference again.

I'm assuming that I'm missing some fundamental (and no doubt embarassingly obvious) issue, and I'll be very grateful to have it pointed out to me.

Following is an example program + app.config that illustrates the same behaviour that I'm experiencing with the real system, i.e. it works perfectly well locally, but when I try to connect (to http://192.168.0.59:8888/DannyService?wsdl or to http://192.168.0.59:8888/DannyService) from any other machine, it times out.

namespace DannyService
{
    using System;
    using System.Reflection;
    using System.ServiceModel;

    [ServiceContract]
    interface IDannyControl
    {
        [OperationContract]
        string SayHi();
    }

    class DannyControl
        : IDannyControl
    {
        public string SayHi()
        {
            return "Hi!";
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ServiceHost host = new ServiceHost(typeof(DannyControl));

            host.Open();

            Console.ReadLine();

            host.Close();
        }
    }
}

and

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DannyServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="DannyService.DannyControl" behaviorConfiguration="DannyServiceBehaviour">
        <host>
          <baseAddresses>
            <add baseAddress="http://192.168.0.59:8888/DannyService"/>
          </baseAddresses>
        </host>
        <endpoint address="danny" binding="basicHttpBinding" contract="DannyService.IDannyControl" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

Many thanks in advance.

DannyT
  • 13,939
  • 1
  • 18
  • 12
  • Can u retrieve the wsdl or view the svc file from the browser on the other machine? – Shawn Mclean Oct 29 '09 at 22:55
  • If you mean putting http://192.168.0.59:8888/DannyService?wsdl in the browser, or in the Add Service Reference dialog, then no. If there's something, then I dunno. ;-/ – DannyT Oct 29 '09 at 23:11
  • Nope. Both just time out. It's a self-hosted service (in a Windows Service). But the example I've posted has the exact same behaviour. Try it! ;-/ – DannyT Oct 29 '09 at 23:31
  • Everything seems just fine - really silly question: is the Windows NT Service up and running, when you attempt to connect to it? Since it's self-hosting, it's your own responsability to make sure the service is running...... – marc_s Oct 30 '09 at 06:47
  • ?wsdl is not used with the basicHttpBinding. It's only http://192.168.0.59:8888/DannyService - have you tried that? – Fedearne Oct 30 '09 at 13:57
  • Thanks for all the hints, but it's not any of those. THis is driving me nuts. Thank you MS/WCF, for making such a simple and easily configured technology! – DannyT Nov 01 '09 at 22:52

1 Answers1

2

Have you made sure that you don't have the firewall service running and blocking those requests? You might need to specifically add an exception rule for your custom host application (or tcp port)

tomasr
  • 13,683
  • 3
  • 38
  • 30