【问题标题】:Changing the IP address on an .NET 2.0 Remoting service breaks new clients from connecting更改 .NET 2.0 远程服务上的 IP 地址会导致新客户端无法连接
【发布时间】:2015-03-08 03:36:36
【问题描述】:

我有一个 C++ Windows 服务,它公开了一个 .Net Remoting 接口供本地客户端使用,并且在 IP 地址更改之前一切正常。

由于我必须支持 .Net 2.0,因此无法切换到 WCF。

关于我能做什么的任何想法?

这是我设置频道的方式:

Hashtable^ dict = gcnew Hashtable();
dict["port"] = 9085;
dict["authenticationMode"] = "IdentifyCallers";
dict["impersonate"] = nullptr;  
dict["secure"] = true;
dict["typeFilterLevel"] = "Full"; 

TcpServerChannel^ tcpChannel;
try
{
  tcpChannel = gcnew TcpServerChannel( dict, nullptr);
}
catch (Exception^ e)
{
}

try
{
  ChannelServices::RegisterChannel(tcpChannel, true);
}
catch (RemotingException^ RemoteException)
{
  return FALSE;
}
catch (Exception^ e)    {    }

MyServiceProxy^ proxy = gcnew MyServiceProxy(m_pService);
RemotingServices::Marshal(proxy,"ServiceProxy");

这是我通过 C# 连接到该服务的方式

    IDictionary dict = new Hashtable();
    dict["port"] = 9085;
    dict["name"] = "127.0.0.1";
    dict["secure"] = true;
    dict["tokenImpersonationLevel"] = "Impersonation";
    dict["typeFilterLevel"] = "Full";
    dict["connectionTimeout"] = 10000; // 10 seconds timeout
    workChannel = new TcpClientChannel(dict, null);
    try
    {
      ChannelServices.RegisterChannel(workChannel, true);
    }
    catch (System.Exception /*e*/)
    {
    }
    string objectPath = "tcp://127.0.0.1:9085/ServiceProxy";
    obj = (IMyService)Activator.GetObject(typeof(IMyService), objectPath);

我的意思是当计算机的 IP 地址发生变化时。所以这里是流程。 启动设置频道的服务,然后关闭笔记本电脑盖,回家,再次打开它,分配一个新的IP地址,现在当我尝试启动客户端时,它无法连接服务。

【问题讨论】:

  • .Net 2.0 已有 10 多年的历史,但我们仍有客户在运行 Server 2003。
  • 对“直到 IP 地址更改”的含义进行一些澄清可能会很有用...确实没有像 127.0.0.1 这样的其他地方 - 不知道您为什么要尝试将其更改为其他任何地方。
  • 很抱歉。我的意思是计算机IP地址更改。所以这里是流程。启动设置通道的服务,然后他们合上笔记本电脑盖,回家,再次打开它,分配一个新的IP地址,现在客户端无法连接服务通道了。
  • 您应该使用此信息编辑问题。此外,我建议澄清问题是否仅与已经运行的客户端有关,或者即使新客户端也无法连接。
  • 我知道新客户端在我退回服务之前无法连接。然后就可以连接了。等到真正的电脑上,我会更新原来的帖子。

标签: c# c++-cli .net-2.0 .net-remoting


【解决方案1】:

经过大量研究,我遇到了“bindTo”参数……我需要做的就是将该参数添加到 TCPServerChannel 字典中。

dict["bindTo"]= "127.0.0.1";

如果这不起作用,我将尝试使用 IPCServerChannel,但幸运的是,我只需要这一行。

想一想,这一行已经引起了如此多的悲痛。

感谢阿列克谢的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多