There
Context:
I write a demo console app -a WCF service which running on Linux by mono, and a console Client which running on Windows 7.
Linux Versoin: Both on Ubuntu and Match-box
Mono Version: 2.10.8.1(On Ubuntu) and 2.10.6(On Match-box)
Issue:
The client could communicate with Service by basicHttpBinding but NOT netTcpBinding.
Exception Info:
Could not connect to net.tcp://192.168.1.220/. The connection attempt lasted for a time span of 00:00:14.0408031. 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.1.220:808.
Service Code:
class Program
{
static void Main(string[] args)
{
try
{
ServiceHost sh = new ServiceHost(typeof(DynIPService.DynIPService));
//sh.AddServiceEndpoint("DynIPServiceContract.IDynIPService", binding, "net.tcp://10.161.66.213:808");
sh.Open();
foreach (var ep in sh.Description.Endpoints)
{
Console.WriteLine("Address: {0}, ListenUri: {1}, ListenUriMode: {2} ", ep.Address, ep.ListenUri, ep.ListenUriMode);
}
Console.WriteLine("Service is running");
}
catch (Exception ex)
{
Console.WriteLine("Error:" + ex.Message);
throw;
}
finally
{
Console.ReadKey();
}
}
}
Service app.config(partial, here i just list the endpoints and bindings)
<services>
<service name="DynIPService.DynIPService" behaviorConfiguration="MyServiceTypeBehaviors" >
<endpoint address="net.tcp://127.0.0.1:808"
binding="netTcpBinding" bindingConfiguration="TCP_Binding"
contract="DynIPServiceContract.IDynIPService"/>
<endpoint address="http://127.0.0.1:123"
binding="basicHttpBinding" bindingConfiguration="HTTP_Binding"
contract="DynIPServiceContract.IDynIPService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="HTTP_Binding">
<security mode="None"></security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="TCP_Binding">
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
Client Code:
class Program
{
static void Main(string[] args)
{
//var ip = "localhost.localdomain";
var ip = "192.168.1.220";
//Tcp
Binding tcpBinding = new NetTcpBinding(SecurityMode.None);
var tcpUri = new Uri(string.Format("net.tcp://{0}:808", ip));
//http
Binding httpBinding = new BasicHttpBinding();
var httpUri = new Uri(string.Format("http://{0}:123",ip));
EndpointAddress address = new EndpointAddress(httpUri.ToString());
IDynIPService proxy = ChannelFactory<IDynIPService>.CreateChannel(httpBinding, address);
var hostIP = proxy.ReadHostIp();
Console.WriteLine(hostIP);
Console.ReadKey();
}
}