graphql-dotnet / graphql-dotnet/graphql-client

WebsocketConnectionState never changes to Connected

Open
#578 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.