dotnet / dotnet/aspnetcore

SignalR ts client transport has unexpected behaviour about transport when calling withUrl() twice

Open
#51,876 0 comments 0 reactions 0 assignees View on GitHub
area-signalr
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

In my project I basically do this:
```
const hubConnectionBuilder = new signalR.HubConnectionBuilder();
const connectionBuilder = hubConnectionBuilder
.withUrl("http://example.com/1", {transport: HttpTransportType.LongPolling})
.build();
```

and at a later point I just want to change the URL so I call:
`connectionBuilder.withUrl("http://example.com/2")`

For me unexpectedly this changes the transport back to original and tries websockets for http://example.com/2 but websockets are blocked so it fails.

I proposed this PR to change this behaviour:
https://github.com/dotnet/aspnetcore/pull/51875

I am new here so I don't expect this pullrequest to be flawless or maybe it won't even get accepted because the behaviour is as designed.

PS: Can you give me a tip how to run the SignalR/ts/signalr tests I'd appreciate it. Wrote the test but didn't know how to execute it except by creating a Pullrequest... Also not sure if my log line really works because it is nullable until build()

### Expected Behavior

calling withUrl() second time without the optional parameter will not overwrite transport from LongPolling with undefined

### Steps To Reproduce

https://github.com/dotnet/aspnetcore/pull/51875

### Exceptions (if any)

_No response_

### .NET Version

"@microsoft/signalr": "^7.0.5",

### Anything else?

In debug logging I receive this unexpected logging:
Debug: Selecting transport 'WebSockets'.
-> altough I've selected LongPolling on first withUrl() call and didn't specify it in second withUrl call

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.