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

Issues (with services.AddSignalR()) #6340

Closed
Nickeron opened this issue May 10, 2018 — with docs.microsoft.com · 30 comments
Closed

Issues (with services.AddSignalR()) #6340

Nickeron opened this issue May 10, 2018 — with docs.microsoft.com · 30 comments
Assignees
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

Copy link

services.AddSignalR(); does not work, and I could not figure out how to fix it.
using Microsoft (.AspNetCore) -> .AspNet .SignalR;


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@scottaddie scottaddie added the Source - Docs.ms Docs Customer feedback via GitHub Issue label May 10, 2018
@rachelappel
Copy link
Contributor

@Nickeron Would you be able to elaborate a bit more so I can understand what's not working?
Is there an error? Where/when does it happen? Or is it behaving oddly with no error? Is there an issue with a using statement? Would you also check which version of VS and ASP.NET you're using?

@Rick-Anderson
Copy link
Contributor

@Nickeron can you elaborate on how it doesn't work? I can't repo the problem and we've had many people report success.

@ImageQC
Copy link

ImageQC commented May 11, 2018

I had the same problem:

public void ConfigureServices(IServiceCollection services) { ... services.AddSignalR(); }

AddSignalR() isn't a method of services.

FIX:

You need to install .NET Core SDK 2.1.300-preview1

https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1

It should then work. I hope this helps.

@Rick-Anderson
Copy link
Contributor

@ImageQC Thanks for reporting the solution.

@rachelappel can you get this fixed Friday morning?

@rachelappel
Copy link
Contributor

@ImageQC @Nickeron Are either of you using the sample when the error occurs or are you trying a new project from scratch (using the File->New Project command)?

@ImageQC
Copy link

ImageQC commented May 11, 2018

Brand new project following your recipe exactly like it was the sainted Mary Berry's lemon drizzle cake ;-)

@rachelappel
Copy link
Contributor

@ImageQC Is it erroring, and if so, what is the error message?

@rachelappel rachelappel changed the title Issues Issues (with services.AddSignalR()) May 11, 2018
@ImageQC
Copy link

ImageQC commented May 11, 2018

In my case installing .NET Core SDK 2.1.300-preview1 fixed the problem as reported above. However, the sample didn't work as reported #6358. The error message was Failed to start the connection. Error: Unable to initialize any of the available transports

@rachelappel
Copy link
Contributor

rachelappel commented May 11, 2018

@ImageQC What results are you getting in the sample? - can you try the sample and see how that works?
Can you print out the elements from your .csproj file?

@ImageQC
Copy link

ImageQC commented May 11, 2018

The source of the problem is the lack of control over package versions. I got the sample working at

The packages are given below. However, God knows where signalr.js comes from as the authors didn't bother to put a version number in the file (a sackable offence in my day). I just copied it and the rest of the script folder into my SpikeWebApp. Perhaps, you could find out and post here. Is this code developed by Microsoft employees, or volunteers?

image

@rachelappel
Copy link
Contributor

@ImageQC What about the Getting Started sample? Are you having issues with that sample?

@ImageQC
Copy link

ImageQC commented May 11, 2018

If you talking about

then, no - it doesn't work. The problem is that you haven't given enough information about the packages, or the information you have given is wrong. I suspect if you gave the information in my previous post and identified the source of the signalr.js then you sample would work. However, I haven't the time to do that work. I'm cancer researcher, not a Microsoft employee ;-)

@rachelappel
Copy link
Contributor

@ImageQC I've opened an issue asking for the version in the JS file. That's a good idea.
We don't sack employees for things like not putting version numbers in JavaScript files.
ASP.NET Core is 100% open source so you can see who is working on it. It is internal employees, but community contributors do occasionally help.

@rachelappel
Copy link
Contributor

@ImageQC The Get Started sample is RC2, so if you use preview bits it will error. The JS file is the latest and matches the server versions in that sample.

@ImageQC
Copy link

ImageQC commented May 11, 2018

Shame - pour encourager les autres as we say in Montreux (Switzerland), or
ఇతరులను ప్రోత్సహించడానికి as they say Hyderabad (my current location).

@ImageQC
Copy link

ImageQC commented May 11, 2018

I hope all this was helpful.

@rachelappel
Copy link
Contributor

I don't understand what "a shame to encourage others" has to do with this issue?

@Rick-Anderson
Copy link
Contributor

Shouldn't the .csproj file be:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>

@rachelappel
Copy link
Contributor

@Rick-Anderson That's what's in the sample.

@Rick-Anderson
Copy link
Contributor

God knows where signalr.js comes from as the authors didn't bother to put a version number in the file (a sackable offence in my day).

It uses the latest version from your NuGet source. I'm getting clarification from the product team on why they are using this approach.

@Rick-Anderson
Copy link
Contributor

Rick-Anderson commented May 12, 2018

In case anyone else reads this issue, @ImageQC .csproj file is not the recommended approach. <PackageReference Include="Microsoft.AspNetCore.App" /> is preferred over multiple packages, and the versions should be RC1, not preview.

The sample has the correct markup. At this point in SignalR development you probably don't want to use a version number. You can lock the version number when it's RTM.

@davidfowl
Copy link
Member

You should be using ASP.NET Core 2.1 rc1. I wouldn't update the docs to show that as we don't talk abut explicit package references to for example, add MVC.

If we do explain that AddMvc is in the Microsoft.AspNetCore.Mvc package then I'd be more receptive to a change like this.

Maybe the SignalR guide needs to explain say "follow the migration guide to upgrade to ASP.NET Core 2.1"

@ImageQC
Copy link

ImageQC commented May 14, 2018

I wasted most of the day trying to get it to work with ASP.NET Core 2.1, but failed due to package version conflicts. The information given in your docs just isn't sufficient. You need to give the .CSPPROJ details, as I did above. I would be delighted if you could give the information needed for me to target Core 2.1, but I started at Core 2.0 on the basis that you need first get the project working and then make your changes. I hope others following your example find the info I provided useful. However, my advice would be to go to the Azure SignalR group. Their sample does work out of the box. Yours should do the same, yes?

https://github.com/aspnet/AzureSignalR-samples/tree/master/samples/ChatRoomLocal

@davidfowl
Copy link
Member

I wasted most of the day trying to get it to work with ASP.NET Core 2.1, but failed due to package version conflicts.

@Rick-Anderson do we have an upgrade guide from 2.0 to 2.1?

The information given in your docs just isn't sufficient. You need to give the .CSPPROJ details, as I did above.

The doc says in the very first paragraph:

image

I hope others following your example find the info I provided useful. However, my advice would be to go to the Azure SignalR group. Their sample does work out of the box. Yours should do the same, yes?

Our samples need updating (which I will do right now):

https://github.com/aspnet/SignalR-samples/

@Rick-Anderson
Copy link
Contributor

New doc: How to upgrade ASP.NET Core 2.0 to 2.1 #6404
I'll make sure it gets completed this week.

@ImageQC
Copy link

ImageQC commented May 14, 2018

The doc says in the very first paragraph: .NET Core 2.1.0 RC1 SDK

You will note that I created a post about just that issue, even containing a link to the download. However, having done that and updated VS2017 to 15.7.1, the samples still didn't work. The problem seems to relate to package incompatibility. Eventually I found a set of packages that did work, but unfortunately only with .NET Core App 2.0. Therefore I posted my .CSPROJ to help anyone else who was struggling with this issue. I rather hoped that the owner and contributors (Microsoft staff?) would then post an update to the .CSPROJ with the required packages for .NET Core App 2.1. Unfortunately, that doesn't seem to have happened yet.

Feedback: Modern software development is not much more than following recipes, so you need to make sure the recipes actually work. It would be very helpful the MS teams creating samples paid more attention to:

  1. Rigorously control their dev environment
  2. Testing the samples in that environment before publishing
  3. Giving exact details of the environment, particularly the .CSPROJ content

I hope everyone can learn from this.

@davidfowl
Copy link
Member

davidfowl commented May 14, 2018

The samples are updated now. We'll do a better job at having those provided for the docs that show code. I agree without something runnable, it's hard to know what the exact steps are.

@Rick-Anderson
Copy link
Contributor

  1. Rigorously control their dev environment
  2. Testing the samples in that environment before publishing
  3. Giving exact details of the environment, particularly the .CSPROJ content

All of that is done automatically with the template generated code. The templates use <PackageReference Include="Microsoft.AspNetCore.App" /> which bring in the right NuGet packages.

@ImageQC
Copy link

ImageQC commented May 15, 2018

Glad to hear you found my feedback useful. If the samples are now working and you've detailed the packages people need to use then we can close this issue, yes?

@8enSmith
Copy link

8enSmith commented Jul 3, 2019

  1. Rigorously control their dev environment
  2. Testing the samples in that environment before publishing
  3. Giving exact details of the environment, particularly the .CSPROJ content

All of that is done automatically with the template generated code. The templates use <PackageReference Include="Microsoft.AspNetCore.App" /> which bring in the right NuGet packages.

As well as specifying the package reference stated above I also had to change the target framework to 2.1 to get this demo project working i.e.

<TargetFramework>netcoreapp2.1</TargetFramework>

Hope that will help anyone else who found it frustrating getting this demo project working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

7 participants