English 中文(简体)
How to handle IP Address rerouting with .NET Remoting
原标题:

I have a process within a network that wants to talk to a service on another network. So I have two computers:

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

With this setup, I can call the Server with the 172.X.X.X ip address and it maps to the 10.0.1.X address and talks fine. However, when I try to use .NET Remoting and communicate, I get an exception:

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:BuildAgentwork78a60abb233492e7SourceAloha.Automation.PresentationViewModelTerminalViewModel.cs:line 167
   at Aloha.Automation.Presentation.ViewModel.TerminalViewModel.Refresh() in c:BuildAgentwork78a60abb233492e7SourceAloha.Automation.PresentationViewModelTerminalViewModel.cs:line 225
   at Aloha.Automation.Presentation.ViewModel.TerminalViewModel.LabConnectorViewModelOnPropertyChanged(Object sender, PropertyChangedEventArgs args) in c:BuildAgentwork78a60abb233492e7SourceAloha.Automation.PresentationViewModelTerminalViewModel.cs:line 154
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at Caliburn.Core.PropertyChangedBase.RaisePropertyChangedEventImmediately(String propertyName) in c:Codecaliburnranchesv1.1srcCaliburn.CorePropertyChangedBase.cs:line 49
   at Aloha.Automation.Presentation.ViewModel.ExtendedPresenter.<>c__DisplayClass1.<NotifyOfPropertyChange>b__0() in c:BuildAgentwork78a60abb233492e7SourceAloha.Automation.PresentationViewModelDetailsViewModel.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)]]>

How should I handle this situation? Do I need to switch remoting technologies or roll my own?

最佳回答

This is not possible with .NET. When you re having ip rerouting issues, switch to WCF.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签