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

How to add Azure SignalR Service in Azure Api application #85

Open
wmktz1 opened this issue Mar 29, 2019 · 14 comments
Open

How to add Azure SignalR Service in Azure Api application #85

wmktz1 opened this issue Mar 29, 2019 · 14 comments

Comments

@wmktz1
Copy link

wmktz1 commented Mar 29, 2019

now i have a problem, we have an asp.net web application`s Azure Api application, start class is Global.asax.cs .
i fllow https://github.com/aspnet/AzureSignalR-samples/tree/master/aspnet-samples/ChatRoom

my question is
1、Azure SignalR Service must in owin?
2、Can Global.asax.cs connect to Azure SignalR Service ?
3、Could you suggest How to add Azure SignalR Service in Azure Api application

Thanks everyone

@hugobarona
Copy link

You can use the REST API. A complete guide here and a console app example here.

@vicancy
Copy link
Contributor

vicancy commented Jun 24, 2019

Hi @wmktz1
Yes, it requires Owin.

Could you suggest How to add Azure SignalR Service in Azure Api application

Not sure what Azure Api Application exactly refers to here. You can create an ASP.NET Web Application with Web Api, and as well adding SignalR functionality, and Publish to Azure App Service.

Please note that REST API does NOT support ASP.NET version SignalR. ASP.NET Core SignalR supports that. cc @hugobarona

@nyakimov
Copy link

@vicancy I was trying to use the aspnet-sample chat app together with the .net core chat app but i don't see the messages coming across. They both connect fine to Azure SignalR but the broadcast messages from one don't show up on the other. Any idea ?

@vicancy
Copy link
Contributor

vicancy commented Dec 19, 2019

@nyakimov ASP.NET SignalR and ASP.NET Core SignalR are using different protocols and they are not recognized by each other.

@nyakimov
Copy link

So what is the advisable method to achieve Azure SignalR communication between .net core and .net full framework applications ?

@nyakimov
Copy link

I just found this https://github.com/Azure/azure-signalr and seems like Azure SignalR supports both ASP.NET Core SignalR and ASP.NET SignalR. I ran two instances of the asp.net-samples/chatroom app which is the ASP.NET but I still can't get the messages to come across from one instance to the other.. very strange

@vicancy
Copy link
Contributor

vicancy commented Dec 30, 2019

Azure SignalR supports both ASP.NET Core SignalR and ASP.NET SignalR

Yes, it supports both protocols, separately. They are using different channels and different message protocols, and they can't talk to each other. You can consider them as different app isolations.

So what is the advisable method to achieve Azure SignalR communication between .net core and .net full framework applications

Interesting question. Could you describe your scenario in a bit more detail? One way I can think of is to have some client implementing both ASP.NET SignalR and ASP.NET Core SignalR. This client can act as an adapter and it can receive messages from one ASP.NET SignalR connection and send messages to the other ASP.NET Core SignalR connection.

@nyakimov
Copy link

Could you describe your scenario in a bit more detail?

I have multiple microservices that process payments and they're all .net core. The payment request gets initiated from a .net full framework and I'm trying to notify the client when the payment goes through the different stages/statuses. I was thinking I can send signalr message from the .net core backend app and receive it in the front end .net full framework app.

I hope that makes sense. I can clarify more it needed.

@vicancy
Copy link
Contributor

vicancy commented Dec 31, 2019

I am thinking, the initiating payment app which uses .net full framework, which version is it? It can also use ASP.NET Core SignalR Client because the SDK is targeting .NETStandard 2.0.

@nyakimov
Copy link

nyakimov commented Jan 3, 2020

It's .NET Framework 4.7.2. I'm going to try to reference the Microsoft.AspNetCore.SignalR.Core package. Would I also have to use the signalr.js for the front end or will the jquery.SignalR library still work ?

@vicancy
Copy link
Contributor

vicancy commented Jan 6, 2020

No the old jquery.SignalR does not work for Core SignalR, they are different. Please follow the instruction for ASP.NET Core SignalR client, the syntax is similar and easy to use.

@nyakimov
Copy link

nyakimov commented Jan 8, 2020

I'm having some trouble hooking up the AspNet Chatroom app (https://github.com/aspnet/AzureSignalR-samples/tree/master/aspnet-samples/ChatRoom) to Azure SignalR using the ASP.NET Core SignalR Client. I'm trying to hook it up in the same manner as the .net core chat app. In the .net core chat app my Startup.cs looks like this:

`// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.Azure.SignalR.Samples.ChatRoom
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

    public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();
        services.AddSignalR()
                .AddAzureSignalR("Endpoint=https://....");

        //services.AddSingleton(new SignalRConsoleClient());
    }

    public void Configure(IApplicationBuilder app)
    {
        app.UseMvc();
        app.UseFileServer();
        app.UseAzureSignalR(routes =>
        {
            routes.MapHub<ChatSampleHub>("/chat");
        });
    }
}

}
`

The Asp.net full framwork chat app startup.cs looks like this:
`// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(ChatRoom.Startup))]

namespace ChatRoom
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Any connection or hub wire up and configuration should go here
app.MapAzureSignalR(GetType().FullName, "Endpoint=https:/....");

        // Turn tracing on programmatically
        GlobalHost.TraceManager.Switch.Level = SourceLevels.Information;
    }
}

}
`
How do I get the asp.net chat app using the .net core signalr client hooked up with the same code ?

@vicancy
Copy link
Contributor

vicancy commented Jan 9, 2020

How do I get the asp.net chat app using the .net core signalr client hooked up with the same code ?

No you can't.

I have multiple microservices that process payments and they're all .net core. The payment request gets initiated from a .net full framework and I'm trying to notify the client when the payment goes through the different stages/statuses. I was thinking I can send signalr message from the .net core backend app and receive it in the front end .net full framework app.

After rereading your description, I feel that I misunderstood your scenario. It should be that your net472 app is the server-side broadcasting messages while your client-side is using .net core, right? I think for this scenario you can directly use ASP.NET Core SignalR for your server side as Microsoft.AspNetCore.SignalR targets netstandard2.0 which is compatible with net472. But please note that you can run all the ASP.NET Core on .NET Framework but not with the previous ASP.NET System.Web stack.

Another approach, if you are to broadcast messages, you can use the Azure SignalR Serverless mode, and use REST API or Management API to broadcast messages. Clients use ASP.NET Core SignalR clients. A serverless sample is here

@nyakimov
Copy link

nyakimov commented Jan 9, 2020

Yes client side is .net 472 and the backend microservices are .net core 2.x I'm trying to get both of them connected to Azure SignalR which I'm able to but apparently they're using the two different protocols and not able to pass messages between each other so I was trying to see how I can get them connected through the same protocol to Azure SignalR instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants