连接尝试失败,因为连接方没有正确响应....NET Remoting [英] A connection attempt failed because the connected party did not properly respond... .NET Remoting

查看:64
本文介绍了连接尝试失败,因为连接方没有正确响应....NET Remoting的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两台计算机上有两个应用程序.这些应用程序通过 .NET Remoting 进行通信.第一个应用程序充当访问数据库的服务器,第二个应用程序充当客户端并将该数据写入另一个数据库.

当我的客户端在服务器上的远程对象上调用某个方法时,我收到以下错误:

<块引用>

连接尝试失败,因为连接方没有一段时间后正确响应,或建立连接失败,因为连接的主机未能响应192.168.200.60:31621

好吧,那很好,但我对 IP 地址 192.168.200.60 一无所知,我正在连接到 172.XXX.XXX.216.似乎有两个网络连接,不知何故不适合远程处理.

ipcongif 在我的服务器上看起来像这样:

完全相同的解决方案适用于另外 3 台装有 Windows 2000、Windows XP 和 Windows 7 的计算机.服务器是在 .NET Framework 2.0 中开发的.

客户端和服务器具有通用的 DLL 库,有两个接口 ICAOFactory 和 ICAO.首先我创建工厂 CAOFactory,它有方法 CreateCAO,它返回 CAO 对象.当我调用某个方法哦那个 ICAO 对象时,它失败了.

这是我的服务器应用程序注册远程对象的方式:

TcpChannel channel = new TcpChannel(31621);ChannelServices.RegisterChannel(channel, false);RemotingConfiguration.RegisterWellKnownServiceType(typeof(My_Server.CAOFactory), "My_Server", WellKnownObjectMode.Singleton);

这是我的客户端创建远程对象的方式:

My_Share.ICAOFactory srvFactory;My_Share.ICAO srvCAO;srvFactory = (My_Share.ICAOFactory)Activator.GetObject(typeof(Foerster_Share.ICAOFactory), "tcp://" + ip + ":" + port + "/My_Server");srvCAO = srvFactory.CreateCAO();//没问题srvCAO.Init(dateTime);//问题

这是我的 CAOFactory 对象:

公共类 CAOFactory : MarshalByRefObject, ICAOFactory{公共国际民航组织 CreateCAO(){国际民航组织 CAOObj = 新的 CAO();返回 CAOObj;}public void GetClientCount(out long clientCountSum, out long clientCountMax, out long clientCountActive){clientCountSum = 0;clientCountMax = 0;clientCountActive = 0;返回;}公共覆盖对象 InitializeLifetimeService(){返回空;}}

这是我的 CAO 对象:

公共类 CAO : MarshalByRefObject, ICAO{公共无效平(){返回;}日期时间 dtInit;公共无效初始化(日期时间 dt){dtInit = dt;}//+ 一些其他方法}

非常感谢任何帮助!

解决方案

重新排序网络连接优先级对我有帮助.

  1. 完成网络连接优先级的组织后,单击确定".现在,当连接可用时,计算机将遵循顺序.

I have two apps on two computers. These apps are communicating by .NET Remoting. First app acts as server for access to database, second app acts as client and writes that data to another database.

When my client calls some method on my remote object on server, I get following error:

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.200.60:31621

Well, that's nice, but I don't know anything about IP address 192.168.200.60, I was connecting to 172.XXX.XXX.216. It seems that there are two network connections and it's somehow not good for remoting.

ipcongif on my server look like that:

Exactly the same solution works on another 3 computers with Windows 2000, Windows XP and Windows 7. Server is developed in .NET Framework 2.0.

Client and server have common DLL library with two interfaces ICAOFactory and ICAO. First I create factory CAOFactory, which has method CreateCAO, which returns CAO object. When I call some method oh that ICAO object, it fails.

This is how my server app registers remoting object:

TcpChannel channel = new TcpChannel(31621); 
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(My_Server.CAOFactory), "My_Server", WellKnownObjectMode.Singleton);

This is how my client creates remote object:

My_Share.ICAOFactory srvFactory;
My_Share.ICAO srvCAO;

srvFactory = (My_Share.ICAOFactory)Activator.GetObject(typeof(Foerster_Share.ICAOFactory), "tcp://" + ip + ":" + port + "/My_Server");
srvCAO = srvFactory.CreateCAO(); // no problem
srvCAO.Init(dateTime); // problem

This is my CAOFactory object:

public class CAOFactory : MarshalByRefObject, ICAOFactory
{
    public ICAO CreateCAO()
    {
        ICAO CAOObj = new CAO();
        return CAOObj;
    }

    public void GetClientCount(out long clientCountSum, out long clientCountMax, out long clientCountActive)
    {
        clientCountSum = 0;
        clientCountMax = 0;
        clientCountActive = 0;
        return;
    }

    public override object InitializeLifetimeService()
    {
        return null;
    }
}

This is my CAO object:

public class CAO : MarshalByRefObject, ICAO
{
    public void Ping()
    {
        return;
    }

    DateTime dtInit;

    public void Init(DateTime dt)
    {
        dtInit = dt;
    }

    // + some other methods
}

Any help greatly appreciated!

解决方案

Reordering network connection priority helped in my case.

http://ecross.mvps.org/howto/change-network-connection-priority-in-windows-10.htm

  1. Press the Windows Key + X and select Network Connections from the menu.
  2. Press the ALT key, click Advanced and then Advanced Settings.
  3. Select the network connection and click the arrows to give priority to the network connection.

  1. Click Ok when you are done organizing the priority of the network connection. The computer will now follow an order when connections are available.

这篇关于连接尝试失败,因为连接方没有正确响应....NET Remoting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆