Version: Any
Problem:
When executing jobs, jobs can fail without starting the PowerShell script. Within the PowerShell Universal logs, you will see an error that states: Did not receive port from client process.
Root Cause:
When running in non-integrated environments, PowerShell Universal jobs are started as external PowerShell processes. Each job will start a new process. When a process is started a communication channel is established to send input and output from the scripts to be stored and displayed within PowerShell Universal. There is a, by default, 5 second time out that the server will wait for the process to communicate back to the server. If this does not happen you will see a "Did not receive port from client process" error within the logs.
Workaround:
There are several ways to work around this issue. Typically, this issue occurs when the server is under load and cannot start the processes fast enough.
Increase Job Timeout
You can increase the timeout of job handshakes. This setting is available in appsettings.json. The following setting increases the job handshake timeout to 30 seconds.
"UniversalAutomation": {
"JobHandshakeTimeout": 30,
"JobDebugging": false,
"ContinueJobOnServerStop": false
},
Reduce Number of Concurrent Jobs
Limiting the number of concurrent jobs can alleviate this issue as well. By reducing the number of jobs running on the system, the jobs will have more resources to use and will not timeout when starting. When the job queue is smaller, jobs will wait to be started before additional jobs are started. This setting is available within the Settings \ General page. By default, the concurrent job limit is 1000. You can try to reduce it as low as you like to avoid this issue.
Increase Resources
Finally, you can also increase resources on the PowerShell Universal system to attempt to avoid this issue. Since the issue is that the jobs are not starting in time, increasing the resources on the machine may improve the jobs ability to complete the handshake within the timeout.