Skip to content

Commit

Permalink
fix(rc): Adjust socket selection for non-faulted connections on net6 …
Browse files Browse the repository at this point in the history
…mobile
  • Loading branch information
jeromelaban committed Jun 27, 2022
1 parent dfc340b commit c31e72d
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/Uno.UI.RemoteControl/RemoteControlClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,19 @@ Uri BuildServerUri()
this.Log().Trace($"Connecting to [{serverUri}]");
}

await s.ConnectAsync(serverUri, ct);
try
{
await s.ConnectAsync(serverUri, ct);
}
catch(Exception e)
{
if (this.Log().IsEnabled(LogLevel.Trace))
{
this.Log().Trace($"Connecting to [{serverUri}] failed: {e.Message}");
}

throw;
}

return (serverUri, s);
}
Expand All @@ -148,6 +160,21 @@ Uri BuildServerUri()
var timeout = Task.Delay(30000);
var completed = await Task.WhenAny(connections.Select(c => c.task).Concat(timeout));

// Wait for any non-faulted task
while (!completed.IsCompletedSuccessfully)
{
var tasks = connections.Select(c => c.task).Where(t => t.Status != TaskStatus.Faulted).ToArray();

if (tasks.Length > 0)
{
completed = await Task.WhenAny(tasks.Concat(timeout));
}
else
{
break;
}
}

foreach (var connection in connections)
{
if (connection.task == completed)
Expand Down

0 comments on commit c31e72d

Please sign in to comment.