自托管WCF TCP连接错误

自托管WCF TCP连接错误,wcf,tcp,Wcf,Tcp,我是WCF新手,遇到了NET.TCP连接问题 这是设置 服务器:Windows8Pro 自托管WCF服务,使用带有SecurityMode的NetTcpBinding。无: try { _serviceHost = new ServiceHost(typeof(MouseTest)); _serviceHost.AddServiceEndpoint(typeof(IMouseTest), new NetTcpBinding(SecurityMode.None),

我是WCF新手,遇到了NET.TCP连接问题

这是设置

服务器:Windows8Pro

自托管WCF服务,使用带有SecurityMode的NetTcpBinding。无:

try
  {
    _serviceHost = new ServiceHost(typeof(MouseTest));
    _serviceHost.AddServiceEndpoint(typeof(IMouseTest), new NetTcpBinding(SecurityMode.None), 
          "net.tcp://localhost:" + MyNetwork.Default.Port.ToString() + "/MyWPFServiceHost");
    _serviceHost.CloseTimeout = new TimeSpan(0,0,5);
    _serviceHost.Open();
    AddMessage("net.tcp open");
  }
  catch (CommunicationException ce)
  {
    // MUST open visual studio as administrator!!!!! (Not this app, but actual VS2010.
    Console.WriteLine("An exception occurred: {0}", ce.Message);
    _serviceHost.Abort();
    AddMessage(ce.Message);
  }
  catch (Exception ex)
  {
    AddMessage(ex.Message);
  }
客户端计算机(各种类型):

private void openTCPServiceButton\u单击(对象发送者,路由目标)
{
String endpointAddress=“net。tcp://XX.XXX.XX.XX:“+MyNetwork.Default.Port.ToString()+”/MyWPFServiceHost”;
if(channelFactory==null)
channelFactory=新的channelFactory(新的NetTcpBinding(SecurityMode.None)),
新端点地址(EndpointAddress));
SendToListBox(channelFactory.Endpoint.Address.ToString());
尝试
{
proxy=channelFactory.CreateChannel();
proxy.StartRecording();
}
捕获(例外情况除外)
{
AddMessageThreadSafe(例如GetType().ToString()+“:”+ex.Message);
}
}
该服务托管在我的家用计算机上,一个Windows 8机箱。当我从同一台机器连接时,一切正常。从同一局域网上的不同机器上,一切正常。从局域网外(在我的办公室机器上),我可以得到:

System.ServiceModel.EndpointNotFoundException:无法连接到 净。tcp://xx.xxx.xx.xx:8085/MyWPFServiceHost. 连接尝试失败 持续时间为00:00:01.1241124。TCP错误代码10061:否 由于目标计算机主动拒绝,因此无法建立连接 它

如果我完全禁用Win8防火墙,则会出现相同的错误

如果我在家里的Windows Server 2008计算机上运行该服务的副本,我可以在任何地方(包括通过互联网)正常连接


拜托,在这三天之后我什么都没有了。还请记住,这是自托管的,而不是IIS托管的。非常感谢您的任何见解或从哪里开始寻找。我已确保此10061错误通常提及的所有服务都已打开。

您是否已选中
MyNetwork.Default.Port.ToString()
在客户端和服务端具有相同的值(8085)?您将此“net”放在哪里。tcp://XX.XXX.XX.XX:“在您的代码中?端口号相同。和XX的只是我的隐私在这里。正如我所说,这项服务在Server2008机器上运行,只是关于Win8机器的问题我搞不懂。你能ping到这个IP吗?你在这两台机器之间还有其他服务吗?你是说在你的路由器上还是在你的计算机上?。。您可以打开命令控制台并执行“netstat/?”。您可以传递一些可选参数/参数来查看侦听端口和相关的正在运行的进程。您还可以下载sysinternalsuite,并运行Tcpview实用程序。
private void openTCPServiceButton_Click(object sender, RoutedEventArgs e)
{
  String endpointAddress = "net.tcp://XX.XXX.XX.XX:" + MyNetwork.Default.Port.ToString() + "/MyWPFServiceHost";

  if (channelFactory == null)
    channelFactory = new ChannelFactory<IMouseTest>(new NetTcpBinding(SecurityMode.None),
      new EndpointAddress(endpointAddress));
  SendToListBox(channelFactory.Endpoint.Address.ToString());
  try
  {
    proxy = channelFactory.CreateChannel();
    proxy.StartRecording();
  }
  catch (Exception ex)
  {
    AddMessageThreadSafe(ex.GetType().ToString() + ": " + ex.Message);
  }
}