Skip to content

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

Closed
@allan-ma

Description

@allan-ma

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?

Activity

ghost

ghost commented on Jan 8, 2025

@ghost

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.

ghost added
untriagedRequest triage from a team member
on Jan 8, 2025
ghost

ghost commented on Jan 8, 2025

@ghost

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.

added
Area-AspNetCoreRazorSDK, BlazorWebAssemblySDK, dotnet-watch
and removed
untriagedRequest triage from a team member
on Jan 14, 2025
nagilson

nagilson commented on Jan 14, 2025

@nagilson
Member

@dotnet/aspnetcore-tooling Please help route this to the correct person for inspection.

removed their assignment
on Jan 14, 2025
BrennanConroy

BrennanConroy commented on Jan 14, 2025

@BrennanConroy
Member

Hi. It looks like this is a question about how to use SignalR. While we do our best to look through all the issues filed here, we are not a general-purpose forum. To get a faster response we suggest posting your questions to StackOverflow using the signalr tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-AspNetCoreRazorSDK, BlazorWebAssemblySDK, dotnet-watch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @BrennanConroy@nagilson@allan-ma

        Issue actions

          ASP.NET Core SignalR Client - The received message is not complete · Issue #45775 · dotnet/sdk