Remoting通信,本机测试通过,局域网内不同机器通信失败。
错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
//服务器监听
int port = 80;
int.TryParse(EditionControlAppMode.Tool.GetConfig("UserServerPort"), out port); TcpServerChannel server = new TcpServerChannel(Guid.NewGuid().ToString(), port);
string virtpath = EditionControlAppMode.Tool.GetConfig("UserServerVirtPath");
if (string.IsNullOrEmpty(virtpath))
virtpath = "aspnet_client";
ChannelServices.RegisterChannel(server, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(EditionControlAppMode.MessageInfo), virtpath, WellKnownObjectMode.SingleCall);
EditionControlAppMode.MessageInfo.SendEventArgs += new EditionControlAppMode.SendEventHandler(MessageInfo_SendEventArgs);客户端/// <summary>
/// 连接客户端
/// </summary>
/// <param name="MsgObj">客户端对象</param>
/// <param name="Ip">客户端IP</param>
/// <param name="Port">客户端端口</param>
/// <param name="VirtPath">虚拟路径</param>
/// <returns></returns>
public bool TelnetClient(ref EditionControlAppMode.MessageInfo MsgObj, string Ip, string Port, string VirtPath)
{
try
{
if (string.IsNullOrEmpty(Ip) || string.IsNullOrEmpty(VirtPath))
return false;
string port = Port;
if (string.IsNullOrEmpty(port))
port = "80";
string url = "tcp://" + Ip + ":" + port + "/" + VirtPath;
BinaryClientFormatterSinkProvider tBinaryProvider = new BinaryClientFormatterSinkProvider(); TcpClientChannel server = new TcpClientChannel(Guid.NewGuid().ToString(), tBinaryProvider);
ChannelServices.RegisterChannel(server, false);
MsgObj = (EditionControlAppMode.MessageInfo)Activator.GetObject(typeof(EditionControlAppMode.MessageInfo), url);
if (MsgObj != null)
{
return true;
}
return false;
}
catch
{
return false;
}
}
IP还有端口什么的都设置的没问题,本地测试可以局域网内不行!!!
错误:由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
//服务器监听
int port = 80;
int.TryParse(EditionControlAppMode.Tool.GetConfig("UserServerPort"), out port); TcpServerChannel server = new TcpServerChannel(Guid.NewGuid().ToString(), port);
string virtpath = EditionControlAppMode.Tool.GetConfig("UserServerVirtPath");
if (string.IsNullOrEmpty(virtpath))
virtpath = "aspnet_client";
ChannelServices.RegisterChannel(server, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(EditionControlAppMode.MessageInfo), virtpath, WellKnownObjectMode.SingleCall);
EditionControlAppMode.MessageInfo.SendEventArgs += new EditionControlAppMode.SendEventHandler(MessageInfo_SendEventArgs);客户端/// <summary>
/// 连接客户端
/// </summary>
/// <param name="MsgObj">客户端对象</param>
/// <param name="Ip">客户端IP</param>
/// <param name="Port">客户端端口</param>
/// <param name="VirtPath">虚拟路径</param>
/// <returns></returns>
public bool TelnetClient(ref EditionControlAppMode.MessageInfo MsgObj, string Ip, string Port, string VirtPath)
{
try
{
if (string.IsNullOrEmpty(Ip) || string.IsNullOrEmpty(VirtPath))
return false;
string port = Port;
if (string.IsNullOrEmpty(port))
port = "80";
string url = "tcp://" + Ip + ":" + port + "/" + VirtPath;
BinaryClientFormatterSinkProvider tBinaryProvider = new BinaryClientFormatterSinkProvider(); TcpClientChannel server = new TcpClientChannel(Guid.NewGuid().ToString(), tBinaryProvider);
ChannelServices.RegisterChannel(server, false);
MsgObj = (EditionControlAppMode.MessageInfo)Activator.GetObject(typeof(EditionControlAppMode.MessageInfo), url);
if (MsgObj != null)
{
return true;
}
return false;
}
catch
{
return false;
}
}
IP还有端口什么的都设置的没问题,本地测试可以局域网内不行!!!
这样可以先排除网络和防火墙之类外因。
主机能ping通虚拟机,虚拟机不能ping通主机。