Connecting to existing Terminal session: Attachmate reflection

Hi Experts,
I have a situation where when the bot is triggered for the first time it needs to login into a terminal(TN3270) and process the transaction. For remaining transactions it should use the existing terminal session , this is to ensure we do not spend too much time logging in, for each transaction.

My idea was to store the connection string in the OutputConnection variable(terminal session activity) and bounce it around so that my workflow latches to the same terminal each time. However i noticed the OutputConnection variable does not capture any value. I have defined it correctly.I am using attachmate reflections as the provider. I read in uipath documentation that attach to existing session is only available while using IBM EEHL standards
Automating Terminals and Mainframes
Section: 2.1.3
How can i achieve this when using attachmate reflection, Would love to here your thoughts .

Hi @Sshankar
sorry for a late response.

What you will want to do is create a Library package so you can share terminal tasks between all your projects. The package will include a Signon xaml, a Close xaml, and a xaml for each application you interact with in your terminal environment.

The Signon xaml should check if the session argument is nothing. If it is nothing, then call the Close xaml (which exits screens to prevent locking things up), then prep any profile configurations / keymapping needed for the applications in your terminal environment.

At the end it should return the session back as an IN/OUT argument. This allows you to call this at the start of each xaml so it can Login if necessary and return the session connection.

If the session argument is not nothing, then it just navigates back to the main menu.

My experience is with EhllSession, where the session connection can be outputting. I am not sure how you would do this without being able to output the session connection. This is because, you must perform the terminal actions inside a Terminal Session, otherwise, you need to use keystrokes, which I don’t recommend except for some things. For example, we do F1-F12 and Enter Command as Send Hotkey cause our terminal emulator is not fully compatible.


Hey Clayton, thanks for the detailed response! I just wanted to confirm – do you know if only the EhllSession will output a TerminalConnection value? I am trying to create a Library Package like you mentioned with Reflection for UNIX; however, the OutputConnection is always ‘null’, as such I cannot connect to an existing instance of the terminal. Any insights you have would be helpful!

I have used ‘Reflection for IBM’ a while back and it worked for me. You did place the variable in the Terminal Session activity?

It might be helpful if you posted images of your code or something. And what you have tried to identify that the variable is null. Also, check the “ContinueOnError”, because sometimes by default it’s “True” so any errors will be ignored.

Hi Clayton, thanks for getting back to me so soon. But yeah, I tested it with a variable and argument (out_tc_TerminalSessionConnection), and even while I am performing actions in the terminal window, the OutputConnection is null. As such, when I pass it to another Terminal Session activity it will error out because no connection is established. The “ContinueOnError” was set to False. Below are some screenshots of the code.

Just wanted to pick your brain incase you did anything different than just passing the Terminal Connection variable.

Hi, Thanks for providing some images.
In the first image that shows the variable as null, I see the yellow box is in an outside scope from the Terminal session activity. It will get set to something after the yellow is inside the Terminal session activity or after it. Can you provide some screenshots of your code after the Terminal session where it is null?

Also, if you have it set as an OUT argument, the connection variable will get reset to null again at the start of that workflow.


Hi @Sshankar,

Did you find any workaround for that?


Hi Clayton,

I’m also running into the OutputConnection set to null after the connection is made. Attached are my screen shots as you had requested above:

My connection settings:

After stepping into the TerminalSession you can clearly see the TerminalConnection is null:

From within the Terminal Session, I need to call another workflow that will logoff the session gracefully. This will be called from multiple locations within the main Terminal Session so I need to be able to pass the TerminalConnection value.




@carlor, I see two TerminalConnection variables. Are you looking at the correct one? And also ensure the variable is set in the Output property of the Terminal Session activity.

I am using the variable ‘tc’ to store the OuptputConnection:

From within this Terminal Session, I am calling my Logout workflow and passing in the TerminalConnection value stored in ‘tc’:

In my logout workflow, I populate the ‘ExistingConnection’ property with the passed in value.

However, it all seems to be moot because the value of ‘tc’ after the TerminalSession starts is null.



Use Direct Connection. It’s much more stable than third party terminal clients.

This is completely unnecessary, and isn’t a solution to their problem.

You have the Close Connection box checked in the Terminal Session activity that first creates the connection and puts it into the tc variable. Uncheck that box.

Nope. No go. I unchecked the box, put a break point inside the Terminal Session and when the session is started and the breakpoint is hit, the value of the OutputConnection is still null.


I don’t think it outputs the connection until it’s done processing everything inside the Terminal Session activity. Let it run. The CloseConnection checkbox is definitely the issue, I’ve made this mistake before.

“CloseConnection” box just closes it at the end of the Terminal Session container.

There is a chance that the connection is delayed a few seconds. Are you pausing it after the delay or before the delay?

In any case, here is an ideal way to ensure the connection is made before continuing with your sequence:

where the ‘Is True’ condition is

I also have a TimeoutMS of 60000 and DelayMS of 1000, cause our emulator sometimes is slow.

I don’t think it outputs the connection until it’s done processing everything inside the Terminal Session activity. Let it run. The CloseConnection checkbox is definitely the issue, I’ve made this mistake before.

@carlor he is right. I tested it on my end and the output is not initialized until after the Terminal Session container is complete. So check your variable after, not inside.


Yeah, it closes at the end of the Terminal Session activity, so the variable is Nothing. You have to leave the connection open.

Just listen to me. Uncheck that box. Let it run. It’ll work now. CloseConnection is the problem.

1 Like

Thank you Clayton and Postwick! That’s what I was missing. I had assumed that OutputConnection parameter worked the same way as scope parameters. I didn’t realize that you had to wait until AFTER the activity Terminal Session finished before the parameter would be populated. If only that was mentioned in the documentation…

Thank you everyone!!


Not necessarily. I have checked my workflows in my Library and CloseConnection is checked, yet it is successfully passing the session variable to outside Terminal Session containers.


But, it would make sense if that did cause an issue with passing the connection around.