private async Task RetryRestoreConnection()

in src/CRA.ClientLibrary/Main/CRAWorker.cs [1080:1139]


        private async Task<bool> RetryRestoreConnection(
            string fromVertexName,
            string fromVertexOutput,
            string toVertexName,
            string toVertexInput,
            bool reverse,
            bool retryForever = true)
        {
            var conn = reverse ? inConnections : outConnections;

            bool killRemote = false;
            bool first = true;

            while (!conn.ContainsKey(fromVertexName + ":" + fromVertexOutput + ":" + toVertexName + ":" + toVertexInput))
            {
                if (!first && !await _connectionInfoProvider.ContainsRow(
                    new VertexConnectionInfo(
                        fromVertex: fromVertexName,
                        fromEndpoint: fromVertexOutput,
                        toVertex: toVertexName,
                        toEndpoint: toVertexInput)))
                {
                    break;
                }
                first = false;

                Trace.TraceInformation("Connecting " + fromVertexName + ":" + fromVertexOutput + ":" + toVertexName + ":" + toVertexInput);
                Trace.TraceInformation("Connecting with killRemote set to " + (killRemote ? "true" : "false"));

                var result = await Connect_InitiatorSide(
                    fromVertexName,
                    fromVertexOutput,
                    toVertexName,
                    toVertexInput,
                    reverse,
                    true,
                    false,
                    killRemote);

                if (result != 0)
                {
                    if (result == CRAErrorCode.ServerRecovering)
                    {
                        if (killRemote && !retryForever)
                            return false;
                        killRemote = true;
                        await Task.Delay(_retryDelayMs);
                    }
                    else
                    {
                        await Task.Delay(_retryDelayMs);
                        if (!retryForever)
                            return false;
                    }
                }
                else
                    break;
            }
            return true;
        }