如何使用.NET Remoting处理IP地址重新路由

时间:2010-04-08 18:54:27

标签: c# .net-remoting

我在网络中有一个想要与另一个网络上的服务通信的进程。所以我有两台电脑:

Client                            Server
172.X.X.X  reroute-> 172.X.X.X to 10.0.1.X

使用此设置,我可以使用172.X.X.X ip地址调用服务器,并将其映射到10.0.1.X地址并进行说明。但是,当我尝试使用.NET Remoting进行通信时,我得到一个例外:

System.Net.Sockets.SocketException: 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 10.0.1.240:8196

Server stack trace: 
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint)
   at System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
   at System.Runtime.Remoting.Channels.RemoteConnection.GetSocket()
   at System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Aloha.Automation.IBackOfHouseFileServer.get_SecurityKey()
   at Aloha.Automation.Presentation.ViewModel.TerminalViewModel.RefreshSecurityKeyFromTerminal() in c:\BuildAgent\work\78a60abb233492e7\Source\Aloha.Automation.Presentation\ViewModel\TerminalViewModel.cs:line 167
   at Aloha.Automation.Presentation.ViewModel.TerminalViewModel.Refresh() in c:\BuildAgent\work\78a60abb233492e7\Source\Aloha.Automation.Presentation\ViewModel\TerminalViewModel.cs:line 225
   at Aloha.Automation.Presentation.ViewModel.TerminalViewModel.LabConnectorViewModelOnPropertyChanged(Object sender, PropertyChangedEventArgs args) in c:\BuildAgent\work\78a60abb233492e7\Source\Aloha.Automation.Presentation\ViewModel\TerminalViewModel.cs:line 154
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at Caliburn.Core.PropertyChangedBase.RaisePropertyChangedEventImmediately(String propertyName) in c:\Code\caliburn\branches\v1.1\src\Caliburn.Core\PropertyChangedBase.cs:line 49
   at Aloha.Automation.Presentation.ViewModel.ExtendedPresenter.<>c__DisplayClass1.<NotifyOfPropertyChange>b__0() in c:\BuildAgent\work\78a60abb233492e7\Source\Aloha.Automation.Presentation\ViewModel\DetailsViewModel.cs:line 42
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)]]>

我该如何处理这种情况?我是否需要切换远程技术或自己动手?

1 个答案:

答案 0 :(得分:2)

.NET无法实现这一点。当您遇到ip重新路由问题时,请切换到WCF。