.Net Remoting 和无法在客户端连接到远程服务器
我创建了一个 Window 服务并在本地计算机上注册了我的 ServerRemoteObject,我的客户端应用程序位于连接到 sSrverRemoteObject 的其他计算机上,并且在本地主机中运行良好(我的计算机位于 LAN 上)。但是,当我使用 global.asax 在 ServerHost 上模拟 Windows 服务并注册远程对象时,当我的客户端应用程序连接到 RemoteServerObject 时,我收到此错误:
错误:“无法连接到远程服务器”
我的 ServerHost 上的 global.asax 中的“Application_Start”:
protected void Application_Start(object sender, EventArgs e)
{
HttpChannel channel = new HttpChannel(9988);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.ApplicationName = "Proxy";
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerRemoteObject),
"Server",
WellKnownObjectMode.Singleton);
}
连接 ServerRemoteObject 的客户端应用程序代码:
Library.IServer serverInstance = (Library.IServer)Activator.GetObject(typeof(Library.IServer), "http://hadeli.somee.com:9988/Proxy/Server");
byte[] bytesRemotibg = serverInstance.Encrypt(GetRequseUrl(value));
byte[] resultProcessRemoting = serverInstance.ProcessToRunning(bytesRemotibg);
I created a Window Service and register my ServerRemoteObject on it in a local computer,my client application is on other computer connecting to sSrverRemoteObject and runs fine in localhost(my computers are on a LAN). But, when i simulation windows service on my ServerHost with global.asax and register the remoteobject,when my client application connect to RemoteServerObject i receive this error:
Error:"Unable to connect to the remote server"
"Application_Start" in global.asax on my ServerHost:
protected void Application_Start(object sender, EventArgs e)
{
HttpChannel channel = new HttpChannel(9988);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.ApplicationName = "Proxy";
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ServerRemoteObject),
"Server",
WellKnownObjectMode.Singleton);
}
Client Application code to connect ServerRemoteObject:
Library.IServer serverInstance = (Library.IServer)Activator.GetObject(typeof(Library.IServer), "http://hadeli.somee.com:9988/Proxy/Server");
byte[] bytesRemotibg = serverInstance.Encrypt(GetRequseUrl(value));
byte[] resultProcessRemoting = serverInstance.ProcessToRunning(bytesRemotibg);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会捕获客户端中的异常,并确保您从中获取所有信息(最好是日志)。内部异常或堆栈跟踪应指示您的客户端是否被允许与端点(包括端口)建立连接,或者服务器是否出现故障。您还应该在服务器中记录任何异常。
第一步是确保您拥有尽可能多的信息。
I would catch the exception in the Client and make sure you are getting all the information out of it (ideally to a log). The Inner Exception or the Stack Trace should indicate if your client is allowed to make a connection to the endpoint (including the port) or if the server is failing. You should also log any exceptions in the server as well.
First step is to make sure you have as much information as it practicable.