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

Exception: The underlying connection was closed before the hub handshake could complete. #104

Open
mamaly12 opened this issue Sep 19, 2023 · 1 comment

Comments

@mamaly12
Copy link

Hi there,

I still have the same issue. I use IdentityServer 4, and the following setup is recommended for signal authentication using the access token(according to https://learn.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-7.0#identity-server-jwt-authentication).

It's not related to the OS, and I am suspicious it's related to the library that cannot update the connection.

  var originalOnMessageReceived = options.Events.OnMessageReceived;
            options.Events.OnMessageReceived = async context =>
            {
                await originalOnMessageReceived(context);

                if (string.IsNullOrEmpty(context.Token))
                {
                    var accessToken = context.Request.Query["access_token"];
                    var path = context.HttpContext.Request.Path;

                    if (!string.IsNullOrEmpty(accessToken) &&
                        path.StartsWithSegments("/hubs"))
                    {
                        context.Token = accessToken;
                    }
                }
            };

When I start a socket connection request, everything seems fine, and the " context.Token" will be set according to the token. Still, suddenly, I received the error "The underlying connection was closed before the hub handshake could complete." from Flutter and my connection will be closed

@dromerolovo
Copy link

Hi @mamaly12 Can you provide your auth pipeline also, and your Hub implementation?

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

2 participants