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.