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

Configuring Stateful Reconnect #31452

Closed
CePur opened this issue Jan 15, 2024 · 12 comments
Closed

Configuring Stateful Reconnect #31452

CePur opened this issue Jan 15, 2024 · 12 comments
Assignees
Labels
seQUESTered Identifies that an issue has been imported into Quest. Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@CePur
Copy link

CePur commented Jan 15, 2024

Description

[Enter feedback here]

Hi, trying stateful reconnect but js throws this exception
"(intermediate value).withUrl(...).withStatefulReconnect is not a function". Using https://unpkg.com/browse/@microsoft/[email protected]/

Page URL

https://learn.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-8.0&tabs=dotnet#configure-stateful-reconnect

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/signalr/configuration.md

Document ID

66d252c3-6300-7e28-9aa0-ef2ff66e7a76

Article author

@bradygaster


Associated WorkItem - 226929

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Jan 15, 2024
@wadepickett wadepickett self-assigned this Jan 15, 2024
@wadepickett
Copy link
Contributor

@CePur, thanks for taking the time to let us know your experience with this doc.
I will cue this doc up to be retested. In the meantime, it would be good to verify the following isn't happening that could result in that error:
Take a look at the .csproj file of your project and note if you are still referencing an old Microsoft.AspNetCore.SignalR.Client.Core. There should not be one in there. Instead, it should be Microsoft.AspNetCore.SignalR.Client and it should be the latest version you were already mentioning. Please let me know if that turns out to be what was happening. Thanks again!

@CePur
Copy link
Author

CePur commented Jan 16, 2024

@wadepickett i don't directly reference it so there is no Microsoft.AspNetCore.SignalR.Client in .csproj. Project is asp.net web project <Project Sdk="Microsoft.NET.Sdk.Web"> targeting net8.0

@wadepickett
Copy link
Contributor

Thanks for the insight!

@wadepickett wadepickett added the reQUEST Triggers an issue to be imported into Quest label Mar 5, 2024
@sequestor sequestor bot added seQUESTered Identifies that an issue has been imported into Quest. and removed reQUEST Triggers an issue to be imported into Quest labels Mar 6, 2024
@wadepickett wadepickett moved this from 🔖 Ready to 🏗 In progress in dotnet/AspNetCore.Docs March 2024 sprint Mar 26, 2024
@wadepickett
Copy link
Contributor

wadepickett commented Mar 27, 2024

@BrennanConroy

With the following set in Program.CS for stateful reconnect:
builder.Services.AddSignalR(o => o.StatefulReconnectBufferSize = 1000);

and

app.MapHub<ChatHub>("/chatHub", options =>
{
    options.AllowStatefulReconnects = true;
});`

The example we had in there for a JavaScript Client was the following:

const builder = new signalR.HubConnectionBuilder()
  .withUrl("/hubname")
  .withStatefulReconnect({ bufferSize: 1000 });  // Optional, defaults to 100,000
const connection = builder.build();

But that example currently in the doc does indeed result in a runtime error that does not recognize withStatefulReconnect as a function:
TypeError: (intermediate value).withUrl(...).withStatefulReconnect is not a function.

Looking in the latest js unpkg package as it downloads (@microsoft/[email protected]) the option .withStatefulReconnect() does not exist so the error makes sense. It is not in there, but that is the latest version you get. Maybe the 8.0 updates did not actually get into that unpkg package?

However, I do see .withStatefulReconnect() defined here: https://unpkg.com/@microsoft/[email protected]/src/HubConnectionBuilder.ts

Am I somehow getting the wrong js package, or the call to HubConnectionBuilder, or for a JavaScript client should I be doing something different such as:

var connection = new signalR.HubConnectionBuilder()
    .withUrl("/chatHub")
    .withAutomaticReconnect()
    .build();

I'll update this doc and the What's new for .NET 8 that had the same example with whatever the correction should be. I'm not sure what the correct client setting should be though.

@wadepickett
Copy link
Contributor

@BrennanConroy, I'm hoping you might be able to take a look a this above. I would have to get the fix in today to get a review in time for this sprint. Sorry to ask, I looked through the source and all related issues and the end result SignalR.js. I'm not able to get it to work as intended.

@BrennanConroy
Copy link
Member

The function does exist, look at line 3474 of https://unpkg.com/browse/@microsoft/[email protected]/dist/browser/signalr.js

I'm guessing they aren't using an 8.0 version of the library.

@wadepickett
Copy link
Contributor

wadepickett commented Apr 5, 2024

Thanks @BrennanConroy. Could you check a new download through the VS libman using unpkg for browser/signalr.js for 8.0.0 or "latest"? I see it on the unpkg site as you pointed out. However, when I add it through Visual Studio using the Library Manager for unpkg and I either specify "latest" or "8.0.0" I receive a version that does not have the word "stateful" anywhere in browser/signalr.js

image

Here is what lines 1177 - 1181 should have in it:

image

The downloaded 8.0.0 signalr.js however is missing the const for DEFAULT_STATEFUL_RECONNECT_BUFFER_SIZE:
image

withServerTimeout(), withKeepAliveInterval() and withStatefulReconnect()should be defined right after withAutomaticReconnect() starting on line 3456 through 3481.
However, in the downloaded 8.0.0 signalr.js through libman for unpkg, those 3 are missing. After withAutomaticReconnect() is defined, then comes build() right after:

image

Should I file a tracking issue? Maybe it is cache issue on unpkg for 8.0.0 or it was not propagated across all their servers?

I checked I also checked jsdelivr, that service for 8.0.0 is fine, withStatefulReconnect and the other new functions are in there as expected.

@BrennanConroy
Copy link
Member

Could you check a new download through the VS libman using unpkg for browser/signalr.js for 8.0.0

Just tried, it has the stateful reconnect code.

@wadepickett
Copy link
Contributor

Interesting. I must be doing something goofy on this end. I get 8.0.0 for jsdelivr just fine, for unpkg 8.0.0 shows up selectable and downloads, but the actual download that arrives is a version before 8.0.0 without stateful reconnect. I started with new projects each test and reboot VS. I have the latest VS. This issue is just for unpkg for me when using libman on VS.

Maybe I am getting a particular server on the farm for unpkg and re-hitting it? That seems slim though, so must be something I am missing on my end given you are not able to recreate. Thanks.

@wadepickett
Copy link
Contributor

Closing since not a doc issue to update here after testing it out.

@CePur
Copy link
Author

CePur commented Apr 30, 2024

I believe i found the issue. For future wanderers:

aspnet/LibraryManager#640 (comment)

@wadepickett
Copy link
Contributor

Awesome, thanks @CePur!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seQUESTered Identifies that an issue has been imported into Quest. Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
No open projects
Development

No branches or pull requests

4 participants