代码之家  ›  专栏  ›  技术社区  ›  Dark Falcon

.NET远程处理连接到错误的主机

  •  1
  • Dark Falcon  · 技术社区  · 15 年前

    我写了一个应用程序,它已经运行了4年了。昨天,他们移动了所有服务器,安装了大约60个挂起的Windows更新,现在它坏了。应用程序利用远程处理更新另一台服务器(10.0.5.230)上的某些信息,但当我尝试创建远程对象时,我得到以下异常: Error message: No connection could be made because the target machine actively refused it 127.0.0.1:9091 http://img692.imageshack.us/img692/8104/screenshot1ay.png

    注意,它试图连接到127.0.0.1,而不是正确的服务器。服务器(10.0.5.230)正在监听端口9091。安装此应用程序的所有三台终端服务器上都会发生相同的错误。

    下面是注册远程对象的代码:

    public static void RegisterClient()
    {
      string lServer;
    
      RegistryKey lKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Shoreline Teleworks\\ShoreWare Client");
      if (lKey == null)
        throw new InvalidOperationException("Could not find Shoretel Call Manager");
    
      object lVal = lKey.GetValue("Server");
      if (lVal == null)
        throw new InvalidOperationException("Shoretel Call Manager did not specify a server name");
    
      lServer = lVal.ToString();
    
      IDictionary props = new Hashtable();
      props["port"] = 0;
      string s = System.Guid.NewGuid().ToString();
      props["name"] = s;
      ChannelServices.RegisterChannel(new TcpClientChannel(props, null), false);
      RemotingConfiguration.RegisterActivatedClientType(typeof(UpdateClient),
        "tcp://" + lServer + ":" + S_REMOTING_PORT + "/");
      RemotingConfiguration.RegisterActivatedClientType(typeof(Playback), 
        "tcp://" + lServer + ":" + S_REMOTING_PORT + "/");
    }
    

    以下是调用远程对象的代码:

    UpdateClient lUpdater = new UpdateClient(Settings.CurrentSettings.Extension.ToString());
    lUpdater.SetAgentState(false);
    

    我已验证以下uri是否传递给了registeractivatedclienttype:“tcp://10.0.5.230:9091/” 为什么此应用程序尝试连接到错误的服务器?

    其他信息:

    客户机确实连接到服务器:它向服务器发送一个constructionCall消息,并接收一个constructionResponse。此constructionResponse包含一个objref,它引用了uri tcp://127.0.0.1:9091。我无法确定这个URI的分配位置。知道服务器为什么会返回这个吗?

    1 回复  |  直到 15 年前
        1
  •  1
  •   Dark Falcon    15 年前

    我发现了问题:远程处理服务器启用了两个网卡,其中一个已拔出。禁用未使用的网卡解决了问题。