Terminal Activities - Close Connection does not work

Hi @bogdan.gaspar,

We’re using Direct Connection for Terminal Sessions with the following connection string:

{'AttachExisting':true, 'ConnectionProtocol':'ProtocolX', 'ConnectionType':1, 
 'EhllSession':'SessionX', 'Host':'MyHost', 'Port':'MyPort', 'ShowTerminal':true}

This connection string is passed as an argument (in_OutputConnection_arg) to multiple Terminal Sessions using the “Existing Connection” property.

The Issue

Initially, the session didn’t work in Debug Mode, but after running it in “Run” mode once, it started working in Debug as well, which was odd. However, we noticed that when a system exception occurs inside a terminal session, the Output Connection arrives empty.

As a result, when we attempt to close the terminal connection using KillAllProcesses and the argument in_OutputConnection_arg, it fails because the connection value is missing.

Our Workaround

To ensure the connection can still be closed:

  • We save the Output Connection of the original terminal session into two arguments:
    1. One argument that passes through all workflows.
    2. Another that is used specifically in KillAllProcesses.

This way, even if an exception occurs mid-execution, we can still close the terminal. When a new session opens (after the exception), we overwrite the two arguments with the new connection value.

Question

This workaround feels a bit “scuffy” (inelegant). Do you have any suggestions for a better way to handle terminal session closures after a system exception occurs?