Ranorex Remote Agent SocketException

Ask general questions here.
dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Ranorex Remote Agent SocketException

Post by dpplgngr » Wed Jul 05, 2017 2:44 pm

Hello,

The Ranorex Remote Agent 2.0.7 logfile.txt shows the following :

Code: Select all

2017-07-05 15:38:15.0214 Ranorex.Dex.Client.Agent.Logic.Bootstrap License will be checked in an interval of '00:30:00' 
2017-07-05 15:38:15.1152 Ranorex.Dex.Client.Agent.LicConfig Will create dual mode broadcast client. 
2017-07-05 15:38:15.1308 Ranorex.Dex.Client.Agent.LicConfig Sending dual mode broadcast. 
2017-07-05 15:38:15.1308 Ranorex.Dex.Client.Agent.LicConfig Starting receive threads. 
2017-07-05 15:38:15.3651 Ranorex.Dex.Client.Agent.LicConfig Will create dual mode TCP client. 
2017-07-05 15:38:15.3651 Ranorex.Dex.Client.Agent.LicConfig Will create dual mode TCP client. 
2017-07-05 15:38:16.1464 Ranorex.Dex.Client.Agent.Views.AgentStatusView Agent started (v2.0.7-6e01397a) 
2017-07-05 15:38:16.1620 Ranorex.Dex.Client.Agent.LicConfig Closing dual mode broadcaster. 
2017-07-05 15:38:16.2089 Ranorex.Dex.Client.Agent.LicConfig Broadcast receive exception: System.Net.Sockets.SocketException (0x80004005): A blocking operation was interrupted by a call to WSACancelBlockingCall
   at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
   at System.Net.Sockets.UdpClient.Receive(IPEndPoint& remoteEP)
   at Ranorex.Libs.DualModeBroadcaster.ReceiveAsync(Object untypedBroadcaster) 
2017-07-05 15:38:16.2089 Ranorex.Dex.Client.Agent.LicConfig V6 broadcast finished. 
2017-07-05 15:38:16.2245 Ranorex.Dex.Client.Agent.LicConfig Broadcast receive exception: System.Net.Sockets.SocketException (0x80004005): A blocking operation was interrupted by a call to WSACancelBlockingCall
   at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
   at System.Net.Sockets.UdpClient.Receive(IPEndPoint& remoteEP)
   at Ranorex.Libs.DualModeBroadcaster.ReceiveAsync(Object untypedBroadcaster) 
2017-07-05 15:38:16.2245 Ranorex.Dex.Client.Agent.LicConfig V4 broadcast finished. 
Any idea what might be the issue ? It seems to point to a problem with the .Net Framework but I have the 4.5.2 version installed. Also, Ranorex 7.1.0 is installed on that machine and works just fine (OS: Windows Server 2008 R2 Standard).

I cannot figure out what the problem is, any help would be appreciated.

Thank you!

Regards,
dpplgngr

dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Re: Ranorex Remote Agent SocketException

Post by dpplgngr » Thu Jul 06, 2017 9:05 am

Also, when I click "Menu > Exit" in the Ranorex Agent client, I get the following in logfile.txt:

Code: Select all

2017-07-06 10:02:21.3961 Ranorex.Dex.Agent.App System.NullReferenceException: Object reference not set to an instance of an object.
   at Ranorex.Dex.Client.Agent.Logic.ViewModels.AgentMainPageViewModel.<.ctor>b__37_0()
   at Ranorex.Dex.Client.Common.DelegateCommand.Execute(Object parameter)
   at Ranorex.Dex.Client.Common.Mvvm.CompositeCommand.Execute(Object parameter)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Ranorex.Dex.Agent.App.Main() 
So far the agent cannot be found by any Ranorex Studio (Remote window), not even the Ranorex Studio installed on the same VM as the agent.

dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Re: Ranorex Remote Agent SocketException

Post by dpplgngr » Thu Jul 06, 2017 9:37 am

Final bump with some info. In the windows application event viewer, I get the following two items every 10 seconds (one INFORMATION item, followed by an ERROR item):

Code: Select all

[INFORMATION] Launching Ranorex Agent 'C:\Program Files (x86)\Ranorex\Agent\RanorexRemoteAgent.exe'...
[ERROR] No active session found.

dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Re: Ranorex Remote Agent SocketException

Post by dpplgngr » Thu Jul 06, 2017 3:12 pm

More info from the Windows Event Viewer.

Code: Select all

[Event 1000, Application Error]
Faulting application name: RanorexRemoteAgent.exe, version: 2.0.7.0, time stamp: 0x59537b7d
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x000007fe9aa98763
Faulting process id: 0x18e4
Faulting application start time: 0x01d2f660049292b0
Faulting application path: C:\Program Files (x86)\Ranorex\Agent\RanorexRemoteAgent.exe
Faulting module path: unknown
Report Id: 6c2b0cbc-6253-11e7-b08e-005056a56d08

Code: Select all

[Event 1026, .NET Runtime]
Application: RanorexRemoteAgent.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at Ranorex.Dex.Client.Agent.Logic.ViewModels.AgentMainPageViewModel.<.ctor>b__37_0()
   at Ranorex.Dex.Client.Common.DelegateCommand.Execute(System.Object)
   at Ranorex.Dex.Client.Common.Mvvm.CompositeCommand.Execute(System.Object)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at Ranorex.Dex.Agent.App.Main()

Code: Select all

[Event 0, AgentLauncher]
No active session found.

dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Re: Ranorex Remote Agent SocketException

Post by dpplgngr » Thu Jul 06, 2017 3:53 pm

The host is a virtual machine running Windows Server 2008 Standard with Service Pack 1.
Ranorex 7.1.0 is installed and works, so all the system requirements for the ranorex agent are covered.

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: Ranorex Remote Agent SocketException

Post by qwertzu » Mon Jul 10, 2017 12:41 pm

Hello dpplgngr,

I would suggest a clean re-install of your Ranorex Agent.
Therefore, please uninstall Ranorex Agent, restart your pc and download/install it from the following link: https://www.ranorex.com/download/remote ... -2.0.7.msi

If this does not help, please try a re-install of Ranorex Studio using the same steps (Uninstall, restart, download/install). For downloading/installing Ranorex Studio, please use this link: https://www.ranorex.com/download/Ranorex-7.1.0.exe

I hope, this helps.

regards,
qwertzu

dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Re: Ranorex Remote Agent SocketException

Post by dpplgngr » Wed Dec 06, 2017 2:11 pm

I figured out the solution a while ago but forgot about this post. I figured I would share the solution, in case someone else experiences the same problem. The difficulty was that there were no logs clearly showing the problem (even the Windows Event viewer was throwing obscure error messages).

The issue is that the default port configured for the Ranorex API is the same as the port used by one of our application running on the machine : namely, the port 8081.

So I edited the following file : C:\Program Files (x86)\Ranorex\Agent\Data\config.toml
and replaced ApiPort = 8081 by ApiPort = 8181 (a port unused by any other application on the machine).

Then I restarted the Ranorex Remote Agent and voilà, it worked.

However, the Ranorex Studio could not find the agent. I could force Ranorex Studio to find the agent by manually specifying the machine name and the port in the "Search manually" field (for instance VM21:8181). I would then be able to "add" the agent to the list. However, Ranorex Studio would then tell me "VM21: Failed to connect to agent." and when I would look at the "Details..." I would see an error message saying :

Code: Select all

Could not connect to http://vm21:8081/api/.   à Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   à Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
   à Ranorex.Dex.Client.Panel.Logic.ViewModels.AgentContainerViewModel.<CreateAgentAsync>d__44.MoveNext()
I did not find a way to tell Ranorex Studio to stop looking at port 8081 but to look at port 8181 instead. So I have changed the port used by the other application to keep 8081 for the Ranorex Agent.

Anyone knows how to tell Ranorex studio to use a different API port ?

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Ranorex Remote Agent SocketException

Post by Vega » Wed Dec 06, 2017 7:46 pm

Don't mean to bring this thread back from the dead but I have some information to share with regards to:

"Anyone knows how to tell Ranorex studio to use a different API port ?"

It is not possible as far as I can tell for Studio and by changing the default port for Agent you break the auto-discovery of Ranorex -> Agent. This is not technically a bad thing, it just means you need to specify the host and port manually like so (at the bottom of the pane to add a remote Agent, there should be a text box that lets you enter the hostname/ip and port manually):

hostname:port
127.0.0.1:8181

dpplgngr
Posts: 13
Joined: Mon Jun 19, 2017 3:00 pm

Re: Ranorex Remote Agent SocketException

Post by dpplgngr » Thu Dec 07, 2017 6:51 am

Vega wrote: hostname:port
127.0.0.1:8181
Which is exactly what I did, as explained in my post. However, once the Agent is added to the list in Ranorex Studio, you cannot connect to it because Ranorex Studio still tries to use the default API port instead of the port manually specified.

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: Ranorex Remote Agent SocketException

Post by Vega » Fri Dec 08, 2017 7:33 pm

Thats strange as I was able to change the port in the toml file, then restarted my Agent. Then when adding the Agent in Ranorex Studio I manually add the Agent like so:

machinename:8181

The Agent then gets added to the list and I can execute from it normally. What error are you getting? Does it even send the test? You can check in Agent by going to the same place where the toml file is stored but then in the Uploads folder. I did have to make new firewall port rules on each machine for the new port that was being used.