I am trying to write a project in C# that uses WCF to have a server that multiple clients can connect to and get sent strings. It works fine on my development machine but when the client is running on a different machine to the server it always fails and I get an error on the clients console:
Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no
endpoint listening at http://henryhunt/SystemControllers/CalculatorService that
could accept the message. This is often caused by an incorrect address or SOAP
action. See InnerException, if present, for more details. ---> System.Net.WebExc
eption: Unable to connect to the remote server ---> System.Net.Sockets.SocketExc
eption: A connection attempt failed because the connected party did not properly
respond after a period of time or established connection failed because connect
ed host has failed to respond 192.168.1.64:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStre
am()
--- End of inner exception stack trace ---
I have checked the URL for the endpoint and it are the same as the server and I don't know what is wrong. Here is my App.config for the service:
="1.0"="utf-8"
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<system.serviceModel>
<services>
<service name="GettingStartedLib.CalculatorService">
<host>
<baseAddresses>
<add baseAddress="http://henryhunt/SystemControllers/CalculatorService" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="GettingStartedLib.ICalculator"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="False" httpsGetEnabled="False" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
The following is the code for the host console not the actual service:
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://henryhunt/SystemControllers/");
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
try
{
selfHost.AddServiceEndpoint(typeof(ICalculator), new WSHttpBinding(), "CalculatorService");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
selfHost.Open();
Console.WriteLine("Press to terminate service");
Console.WriteLine();
Console.ReadLine();
selfHost.Close();
}
catch (CommunicationException ce)
{
Console.WriteLine("An exception was thrown: {0}", ce.Message);
selfHost.Abort();
}
}
This is the App.config file for the client:
="1.0"="utf-8"
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ICalculator" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://henryhunt/SystemControllers/CalculatorService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
contract="ServiceReference1.ICalculator" name="WSHttpBinding_ICalculator">
<identity>
<userPrincipalName value="HENRYHUNT\Henry" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
I really do not know why it cannot access the server from another computer and I have been trying for ages. Please help me, thank you.