graphql-client
graphql-client copied to clipboard
WebsocketConnectionState never changes to Connected
this doesn't happen always, but it happens quite often and out of the 7 services I am connecting to, there is one, that causes this most often, but it's not limited to this one only, it can be related to the order in which they are started
when InitializeWebsocketConnection Task is completed, WebsocketConnectionState is still Disconnected, so I am waiting for it to change to Connected, but it never changes Reconnecting then results in immedate connection with the correct state
foreach (var client in _graphQlClients)
{
var connectionTask = client.Value.InitializeWebsocketConnection();
connectionTasks.Add(client.Key, (connectionTask, client.Value));
stateTasks.Add(client.Key, client.Value.WebsocketConnectionState.Where(x => x == GraphQLWebsocketConnectionState.Connected).Take(1).ToTask());
}
var delayTask = Task.Delay(TimeSpan.FromSeconds(_appSettings.DcConnectionTimeoutSeconds));
var sw = Stopwatch.StartNew();
await Task.WhenAny(Task.WhenAll(connectionTasks.Values.Select(x => x.Task).Concat(stateTasks.Values)), delayTask);
Is there some more reliable source of truth that would tell me if the connection was established? it is possible to ignore the fact that the state is Disconnected and use the connection, it works, so the problem is just with the state not being updated