Great @alb-6 ! Your simple algorithm avoids turning Opta into a opening-socket machine gun. Even though very powerful, Opta -and every single machine- has limited resources. Moreover, pausing between reconections help you to deal with some firewalls than can detect connection rate abuse and block you.
Generally speaking, handle carefully your socket instead open and close multiple, it improves application responsiveness and bandwidth.