private static void ConnectMf()
        {
            Logger.Log(LogLevel.DEBUG, "conecting to mf");
            bool connected = false;

            isMfConnecting = true;
            int i = 1;

            while (!connected && !stopConnecting)
            {
                i = Math.Min(60, i);
                i++;
                Task.Delay(i * 1000).Wait();

                con_mf1.Connect();
                if (con_mf1.IsConnected)
                {
                    curr_mf   = con_mf1;
                    connected = true;
                    Logger.Log(LogLevel.DEBUG, "conection1 mf succ");
                }
                else
                {
                    if (con_mf2 != null)
                    {
                        con_mf2.Connect();
                        if (con_mf2.IsConnected)
                        {
                            curr_mf   = con_mf2;
                            connected = true;
                            Logger.Log(LogLevel.DEBUG, "conection2 mf succ");
                        }
                        else
                        {
                            Logger.Log(LogLevel.DEBUG, "both con1 & con2 mf failed, trying again");
                            Task.Delay(1000).Wait();
                        }
                    }
                }
            }

            if (curr_mf != null)
            {
                curr_mf.ReconnectAction = ReconnectMf;
                curr_mf.SendLogin();
                curr_mf.RequestJob();
            }

            isMfConnecting = false;
        }
        public static void TryPrimary()
        {
            if (con_m1?.IsConnected == false)
            {
                if (con_m2?.IsConnected == true)
                {
                    con_m1.Connect();
                    if (con_m1?.IsConnected == true)
                    {
                        con_m1.ReconnectAction = ReconnectMain;
                        con_m1.SendLogin();

                        curr_m = con_m1;
                        curr_m.RequestJob();

                        con_m2.StratumClose();
                    }
                }
            }
        }
        private static void ConnectMain(bool chooseRandom = false)
        {
            bool connected = false;

            DateTime started = DateTime.Now;

            int i   = 1;
            var rnd = new Random(DateTime.Now.Millisecond);

            while (!connected && !stopConnecting)
            {
                if (DateTime.Now - started > TimeSpan.FromSeconds(60))
                {
                    //main connection not available for more than 60s
                    PauseAllMining();
                }

                i = Math.Min(60, i);
                i++;
                Task.Delay(i * 1000).Wait();

                var flip = rnd.NextDouble();
                Logger.Log(LogLevel.DEBUG, $"reconnecting rnd {flip}");
                //

                if (chooseRandom)
                {
                    if (flip < 0.5)
                    {
                        con_m1.Connect();
                        if (con_m1.IsConnected)
                        {
                            curr_m    = con_m1;
                            connected = true;
                            Logger.Log(LogLevel.DEBUG, "conection1 succ");
                        }
                    }
                    else
                    {
                        con_m2.Connect();
                        if (con_m2.IsConnected)
                        {
                            curr_m    = con_m2;
                            connected = true;
                            Logger.Log(LogLevel.DEBUG, "conection2 succ");
                        }
                    }
                }
                else
                {
                    con_m1.Connect();
                    if (con_m1.IsConnected)
                    {
                        curr_m    = con_m1;
                        connected = true;
                        Logger.Log(LogLevel.DEBUG, "conection1 succ");
                    }
                    else
                    {
                        if (con_m2 != null)
                        {
                            con_m2.Connect();
                            if (con_m2.IsConnected)
                            {
                                curr_m    = con_m2;
                                connected = true;
                                Logger.Log(LogLevel.DEBUG, "conection2 succ");
                            }
                            else
                            {
                                Logger.Log(LogLevel.DEBUG, "both con1 & con2 failed, trying again");
                                //Task.Delay(1000).Wait();
                            }
                        }
                    }
                }
            }

            if (curr_m != null)
            {
                curr_m.ReconnectAction = ReconnectMain;
                curr_m.SendLogin();
                curr_m.RequestJob();
            }
        }