Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebsocketConnectionState never changes to Connected #578

Open
drvic10k opened this issue Jun 16, 2023 · 0 comments
Open

WebsocketConnectionState never changes to Connected #578

drvic10k opened this issue Jun 16, 2023 · 0 comments

Comments

@drvic10k
Copy link

drvic10k commented Jun 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant