If its failing at a stage sometimes , its definitely due to the speed as control room speed is much faster than when we run a process manually or debug mode. I would recommend to use "is connected" after attach and to see if it its successful , if not simply put a recover and try attaching again with a counter of 3 times .
------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification and Optimization Designer(Solutions Architect)
Fidelity International
------------------------------
------------------------------
------------------------------
Vipul Tiwari
Senior Process Simplification Developer
Amazon
------------------------------