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

Does @microsoft/signalr support react-native? #60606

Open
1 task
SergeyAlexeev opened this issue Feb 25, 2025 · 1 comment
Open
1 task

Does @microsoft/signalr support react-native? #60606

SergeyAlexeev opened this issue Feb 25, 2025 · 1 comment
Labels
area-signalr Includes: SignalR clients and servers

Comments

@SergeyAlexeev
Copy link

SergeyAlexeev commented Feb 25, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm trying to connect to signalr service from my react-native app using the @microsoft/signalr npm package v8.0.7

new HubConnectionBuilder()
      .withUrl('wss://my_signalr_service', {
        transport: HttpTransportType.WebSockets,
        skipNegotiation: true,
      })
      .withAutomaticReconnect()
      .configureLogging(LogLevel.Debug)
      .build()

I've got the error from the _resolveUrl method of the HttpConnection class:

Cannot resolve wss://my_signalr_service

In the call stack I've found this line:

if (!Utils_1.Platform.isBrowser) {
    throw new Error(`Cannot resolve '${url}'.`);
}

So, it looks like React Native is not supported at all?

Expected Behavior

@microsoft/signalr connects to a service url from react-native app or it throws the explicit error that provides more information.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-signalr Includes: SignalR clients and servers label Feb 25, 2025
@SergeyAlexeev
Copy link
Author

I found the issue in HttpConnection.js.

The _resolveUrl method can't work with url that starts with wss in react native. But in browser it works fine. I think, the behaviour in browser and in react native should be the same to reuse one code base, for instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

No branches or pull requests

1 participant