Test Orchestrator Connectivity for Robot Service

Test Orchestrator Connectivity for Robot Service.

Issue Description: This article explains how to test Robot Service connectivity even when no one is logged in to the machine.

Background: The Robot Service for unattended installations is always running under LocalSystem. It requires the ability to connect to the Orchestrator endpoint. In a standard windows server, this should be possible but in some scenarios we have seen security software break this connection until someone logs in.


This article provides a way to test the connection independently of UiPath software. This can help eliminate if something is a problem with the UiPath application or a problem with the configuration of the windows machine.

Connection Test

  1. Admin Access is required for this test
  2. This tool will try to connect to the provided endpoint every 30 seconds
  3. Below is a script to use for the test. Create this as a file in a convenient location. The file name should be OrchestratorTest.ps1. (This is a test and the file can be removed afterwards. An easy location to use is C:\Temp, but it may be required to make this folder. It can be deleted afterwards.)
    1. There are two variations. Proxy and No Proxy (More variations in the Appendix)
      1. Proxy
        1. # OrchestratorTest.ps1
          # This script makes a GET request to the specified endpoint every 30 seconds and logs the response
          

          Define the endpoint URL

          $endpointUrl = ‘http://orchestratorURL

          Define the proxy settings

          $proxyUrl = ‘http://proxy

          Define the log directory and file path

          $logDir = “C:\Temp”
          $logFile = “$logDir\LogFile.txt”

          Create the log directory if it doesn’t exist

          if (-Not (Test-Path -Path $logDir)) {
          New-Item -Path $logDir -ItemType Directory
          }

          Create or clear the log file at the start of the script

          Clear-Content -Path $logFile -ErrorAction SilentlyContinue

          Define the request timeout in seconds

          $requestTimeout = 30

          Infinite loop

          while ($true) {
          try {
          # Make the GET request using the proxy
          $response = Invoke-WebRequest -Uri $endpointUrl -Method Get -Proxy $proxyUrl -TimeoutSec $requestTimeout -UseBasicParsing
          $statusCode = $response.StatusCode
          $responseContent = $response.Content
          } catch {
          $statusCode = $.Exception.Response.StatusCode.value__
          $responseContent = $
          .Exception.Message
          }

          # Log the response
          $logEntry = "[$(Get-Date)] Status Code: $statusCode, Response: $responseContent"
          $logEntry | Out-File -FilePath $logFile -Append
          
          # Wait for 30 seconds before the next iteration 
          Start-Sleep -Seconds 30
          

          }

      2. No Proxy
        1. # OrchestratorTest.ps1
          # This script makes a GET request to the specified endpoint every 30 seconds and logs the response
          

          Define the endpoint URL

          $endpointUrl = ‘http://orchestratorURL

          Define the log directory and file path

          $logDir = “C:\Temp”
          $logFile = “$logDir\LogFile.txt”

          Create the log directory if it doesn’t exist

          if (-Not (Test-Path -Path $logDir)) {
          New-Item -Path $logDir -ItemType Directory
          }

          Create or clear the log file at the start of the script

          Clear-Content -Path $logFile -ErrorAction SilentlyContinue

          Define the request timeout in seconds

          $requestTimeout = 30

          Infinite loop

          while ($true) {
          try {
          # Make the GET request using the proxy
          $response = Invoke-WebRequest -Uri $endpointUrl -Method Get -TimeoutSec $requestTimeout -UseBasicParsing
          $statusCode = $response.StatusCode
          $responseContent = $response.Content
          } catch {
          $statusCode = $.Exception.Response.StatusCode.value__
          $responseContent = $
          .Exception.Message
          }

          # Log the response
          $logEntry = "[$(Get-Date)] Status Code: $statusCode, Response: $responseContent"
          $logEntry | Out-File -FilePath $logFile -Append
          
          # Wait for 30 seconds before the next iteration
          Start-Sleep -Seconds 30
          

          }

  4. After creating the file, make some modifications.
    1. Replace http://orchestratorURL with the Orchestrator URL
    2. If using a proxy, replace http://proxy with the proxy
      1. If the proxy uses credentials, see the appendix for the correct script
  5. With the changes in place, try running the script and verify it works. The default location for the logs is in C:\Temp. Make sure to have write access to this location. This location can be changed if needed.
    1. Here is an example output from the tool
      1. Successful - We do not include the full output but the script captures the response body.
        1. [06/12/2024 18:14:57] Status Code: 200, Response: 
          
          
          
          IIS Windows Server
          

      2. Timeout
        1. [06/12/2024 18:13:28] Status Code: , Response: Unable to connect to the remote server
          [06/12/2024 18:14:19] Status Code: , Response: Unable to connect to the remote server
          
  6. Once any issues running the script have been sorted out, create a task to trigger the job
    1. Open Task Scheduler
    2. Select Create Task
image.png
  1. Name the task 'OrchestratorTask'
  2. Under Security Options select 'Change User or Group'
image.png
  1. In the Pop-Up type 'System' and then click Check Names. After this click OK. Setup should look like below screenshot.
image.png
  1. In the security settings, select 'Run with highest privileges"
image.png
  1. In the Triggers tab select 'New'. Change the field 'Begin the task' to 'At Startup'
image.png
  1. Under the Actions tab select 'New'
  2. The action should be 'Start a program'
  3. The other settings are:
    1. Program/script: 'powershell.exe.
    2. Arguments: -NoProfile -ExecutionPolicy ByPass -File "C:\Temp\OrchestratorTest.ps1"
      1. Make sure to update the path if different from 'C:\Temp'
  4. Final setup should look like:
image.png
  1. Select 'OK' and then Select 'OK' in the task definition window.
  2. Next, go to the 'Task Scheduler Library' and run the OrchestratorTest task.
image.png
  1. On the right side of the screen select 'Run'
image.png
  1. Make sure a log file is generated.
  2. If no log file is generated then its not working. Things to check:
    1. From the command line run: powershell.exe -NoProfile -ExecutionPolicy ByPass -File "C:\Temp\OrchestratorTest.ps1"
      1. Replace the path as needed. This is exactly what the task should be executing.
    2. Enable the logs for Task Scheduler (in the task definition its an option on the right).
    3. Check anti virus. Running a script like this might get flagged as it could look suspicious.
  3. Once the setup is complete, take steps to reproduce the issue. Usually this type of issue starts after a reboot.
  4. To delete the task, select the Task in Task Scheduler Library and select 'Delete' on the right panel actions menu.
  5. If the logs show a connection, but the Robot Service still has connection errors, this would indicate the issue is with UiPath software or the Robot configuration.
    1. Probably misconfigured proxy settings. See here
    2. It could also be the Robot Service is not running in service mode. But if this is the case, no logs would be generated by the Robot Service when no user is logged in.
  6. If the logs do not show a connect, that would indicate the connection issue has nothing to do with UiPath and is a more general issue with the computer configuration.
    1. Unattended Robots require a connection to Orchestrator when running a service. If the Robot cannot connect to Orchestrator, because the machine itself has a broken network issue, the problem needs to be addressed by your network team or windows admin. This is not expected behavior.
    2. As an analogy, if there was a power outage and that prevents your computer from turning on, would you contact the power company or the computer manufacturer? The computer manufacturer would probably be able to identify the computer is getting no power, but you would need to contact the power company to get things working.

Appendix

  • Proxy Windows Credentials:
# OrchestratorTest.ps1
# This script makes a GET request to the specified endpoint every 30 seconds and logs the response

# Define the endpoint URL
$endpointUrl = 'http://orchestratorURL'

# Define the proxy settings
$proxyUrl = 'http://proxy'
$domain = "your-domain"
$proxyUsername = "your-username"
$proxyPassword = "your-password"

# Create a PSCredential object for the proxy
$securePassword = ConvertTo-SecureString $proxyPassword -AsPlainText -Force
$proxyCredential = New-Object System.Management.Automation.PSCredential ("$domain\$proxyUsername", $securePassword)

# Define the log directory and file path
$logDir = "C:\Temp"
$logFile = "$logDir\LogFile.txt"

# Create the log directory if it doesn't exist
if (-Not (Test-Path -Path $logDir)) {
    New-Item -Path $logDir -ItemType Directory
}

# Create or clear the log file at the start of the script
Clear-Content -Path $logFile -ErrorAction SilentlyContinue

# Define the request timeout in seconds
$requestTimeout = 30

# Infinite loop
while ($true) {
    try {
        # Make the GET request using the proxy
        $response = Invoke-WebRequest -Uri $endpointUrl -Method Get -Proxy $proxyUrl -ProxyCredential $proxyCredential -TimeoutSec $requestTimeout -UseBasicParsing
        $statusCode = $response.StatusCode
        $responseContent = $response.Content
    } catch {
        $statusCode = $_.Exception.Response.StatusCode.value__
        $responseContent = $_.Exception.Message
    }

    # Log the response
    $logEntry = "[$(Get-Date)] Status Code: $statusCode, Response: $responseContent"
    $logEntry | Out-File -FilePath $logFile -Append

    # Wait for 30 seconds before the next iteration
    Start-Sleep -Seconds 30
}
  • Proxy Non Windows Credentials
# OrchestratorTest.ps1
# This script makes a GET request to the specified endpoint every 30 seconds and logs the response

# Define the endpoint URL
$endpointUrl = 'http://orchestratorURL'

# Define the proxy settings
$proxyUrl = 'http://proxy'
$proxyUsername = "your-username"
$proxyPassword = "your-password"

# Create a PSCredential object for the proxy
$securePassword = ConvertTo-SecureString $proxyPassword -AsPlainText -Force
$proxyCredential = New-Object System.Management.Automation.PSCredential ($proxyUsername, $securePassword)

# Define the log directory and file path
$logDir = "C:\Temp"
$logFile = "$logDir\LogFile.txt"

# Create the log directory if it doesn't exist
if (-Not (Test-Path -Path $logDir)) {
    New-Item -Path $logDir -ItemType Directory
}

# Create or clear the log file at the start of the script
Clear-Content -Path $logFile -ErrorAction SilentlyContinue

# Define the request timeout in seconds
$requestTimeout = 30

# Infinite loop
while ($true) {
    try {
        # Make the GET request using the proxy
        $response = Invoke-WebRequest -Uri $endpointUrl -Method Get -Proxy $proxyUrl -ProxyCredential $proxyCredential -TimeoutSec $requestTimeout -UseBasicParsing
        $statusCode = $response.StatusCode
        $responseContent = $response.Content
    } catch {
        $statusCode = $_.Exception.Response.StatusCode.value__
        $responseContent = $_.Exception.Message
    }

    # Log the response
    $logEntry = "[$(Get-Date)] Status Code: $statusCode, Response: $responseContent"
    $logEntry | Out-File -FilePath $logFile -Append

    # Wait for 30 seconds before the next iteration
    Start-Sleep -Seconds 30
}