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

ASP.NET Core SignalR Client - The received message is not complete #45775

Open
allan-ma opened this issue Jan 8, 2025 · 2 comments
Open

ASP.NET Core SignalR Client - The received message is not complete #45775

allan-ma opened this issue Jan 8, 2025 · 2 comments
Labels
untriaged Request triage from a team member

Comments

@allan-ma
Copy link

allan-ma commented Jan 8, 2025

How to reproduce

[Test]
public async Task SendToOthersInChannelTest1()
{
    for (var i = 0; i < 100; i++)
    {
        var channel = $"channel-{Guid.NewGuid()}";
        var msg = new TestMessage { Msg = "Hello" };
        var ch = Channel.CreateUnbounded<TestMessage>();

        await using (var connection = await HubClient.ConnectAsync(config.Endpoint, config.TenantName, config.ClientId, accessKey)) //connect to our signalr server
        await using (var connection1 = await HubClient.ConnectAsync(config.Endpoint, config.TenantName, config.ClientId, accessKey))
        {
            await connection.InvokeAsync<string>("JoinChannel", channel); //this will trigger a method in the server side, the server just add the connection to the channel, it will call groupManager.AddToGroupAsync(connectionId, channel, cancellationToken)
            await connection1.InvokeAsync<string>("JoinChannel", channel);

            connection.On<TestMessage>(Helper.DefaultMethod, receivedMsg => {
                return ch.Writer.WriteAsync(receivedMsg).AsTask();
            });

            await connection1.InvokeAsync("SendToOthersInChannel", channel, msg); //send the msg to all other users of channel

            var cts = new CancellationTokenSource();
            cts.CancelAfter(TimeSpan.FromMinutes(5));

            var received = await ch.Reader.ReadAsync(cts.Token);

            Assert.True(received.Equals(msg), $"SendToOthersInChannelTest1({i}) receive check failed: {channel} {msg.GetType()}-{msg} {received.GetType()}-{received}");
        }
    }
}

This test will fail stably after run several times when I connect the server that deployed in the azure kubernetes cluster, the Message field of the received TestMessage is empty like below, but can't reproduce it when I connect to the server in my local computer.

 SendToOthersInChannelTest1(0) receive check failed: channel-3cfcf029-312b-43a4-a173-787e43c1e564 TestMessage-Hello TestMessage-
  Expected: True
  But was:  False

When connect to server that deployed in the azure kubernetes cluster, I capture the traffic with fiddler, and it shows that the entire message is received.
rcs.zip

I'm not sure it's an issue of signalr client or my misusage or misconfiguration, can anyone give some hints about how to fix this issue?

Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Jan 8, 2025
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant