Skip to content

SignalR client not reporting version correctly #62864

@lukedukeus

Description

@lukedukeus

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the ts/js signalr library, if you write your own hub protocol that implements signalR.IHubProtocol, the version number is always reported as 1, even if you set it to something else.

I have an ASP.NET Core project that has a GRPC API, so I thought it made sense to use protobuf serialization instead of JSON serailization for my hubs. I wrote a C# class that implements IHubProtocol that looks like this:

    public class ProtobufProtocol : IHubProtocol
    {
        public string Name => "protobuf";

        public int Version => 3;

        public TransferFormat TransferFormat => TransferFormat.Binary;

        public bool IsVersionSupported(int version)
        {
            return Version == version;
        }

        ... omitted for berevity ...
    }

I then wrote the corresponding implementation in TS, but this time, implementing signalR.IHubProtocol:

export class ProtobufProtocol implements signalR.IHubProtocol {
	name = "protobuf";
	version = 3;
	transferFormat = TransferFormat.Binary;

        ... omitted for berevity ...
}

The result is that C# clients can connect to the hub fine, but TS clients cannot, and the error that they recieve is: SignalR connection failed Error: Server returned handshake error: The server does not support version 1 of the 'protobuf' protocol.. I would not expect this error, because neither end of the protocol reports to be version 1.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions