Questions tagged [asp.net-core-signalr]

0

votes
0

answer
3

Views

signalr core - how to call hub method from client

I'm adding SignalR to my app. I can send messages from server to client, but can't call hub methods from client. Here's my hub interface: public interface IGeneralHub { Task BroadcastMessage(HubMessage msg); //string type, string payload); Task JoinHub(List ids); } and hub client: public class Aucti...
Jamil
4

votes
0

answer
98

Views

Wobbly connection between javascript SignalR client and .net core backend

My JavaScript SignalR client routinely connects to my asp.net core implementation of IdentityServer4. On the client I see: Information: WebSocket connected to wss://localhost:5001/signal/satellite? idsrv.session=4ec93d2f4c3b9a970ff82a537ae04d97&id=0eUBg2-xobp4CNttuIQJcg But, it also doesn't connec...
ScottFoster1000
0

votes
0

answer
3

Views

signalr core & policy based authorization : resource always null

Im using signalr core and its working with role based authorization. On the other hand my ClientIdHandler is working just fine in a test mvc controller with [Authorize(Policy = "ClientIdPolicy")], here is the code of the requirement : public class ClientIdHandler : AuthorizationHandler { protected o...
dafriskymonkey
1

votes
3

answer
1.9k

Views

UserId in SignalR core

I'm using SignalR with Asp.Net core 2.0 and I'm trying to send a notification for a specific user like this: _notification.Clients.User(id).InvokeAsync("SendMes"); where _notification is IHubContext. But it doesn't work. When I send the notification for all users everything is fine and all users get...
Artyom
1

votes
1

answer
410

Views

Why does SignalR convert the first letters of Dictionary keys to lower case when it serializes the dictionary and sends it to clients?

This is what is being sent from the server to the client: public class BattleHub : Hub { public override async Task OnConnectedAsync() { await Clients.Client(Context.ConnectionId).SendAsync("ConfigurationInfo", new Dictionary { { "WtF", "WtF" } }); await base.OnConnectedAsync(); } } This is what the...
gaazkam
0

votes
0

answer
3

Views

ASP.NET Core SignalR getting stormed with /negotiate calls

I am using ASP.NET Core 2.2 and have a chat application implemented. I implemented the reconnect this way: this._hub.onclose(() => { if (this.debug) console.debug('hub connection closed'); hub connection was closed for some reason let interval = setInterval(() => { // try to reconnect hub every 5 se...
Matteo
2

votes
2

answer
170

Views

Getting a value sent by SignalR with AngularJS

I'm trying to write a very simple message on the screen that when signalr send a value this message gets updated. I have a very simple Hub: public class Chat : Hub { public Task Send(string message) { return Clients.All.InvokeAsync("Send", message); } } On the front-end I have the following html: An...
Bojan
0

votes
1

answer
3

Views

SignalR Core: invalid negotiation response received in a .Net app

I get this error when connecting to a .Net Core SignalR server with a .Net Framework SignalR Core client. How to solve it?
Mikhail Orlov
17

votes
2

answer
12.1k

Views

Call SignalR Core Hub method from Controller

How can I call SignalR Core Hub method from Controller? I am using ASP.NET Core 2.0 with Microsoft.AspNetCore.SignalR (1.0.0-alpha2-final). I have windows service which communicate with Excel, SolidEdge ... When operation is complete it post request to my controller in ASP.NET Core application. Now...
Makla
6

votes
1

answer
1.1k

Views

Get SignalrR ConnectionId on ClientSide (Angular App)

Hi I'm using an angular app to connect to signalr, I am using "@aspnet/signalr": "1.0.0-preview1-final". I need to send the connectionId to my controller (I need to do some process and tell all others clients but no the user making the request), the problem is Connection Id is private, there is a w...
VictorV
3

votes
1

answer
76

Views

Messages not coming thru to Azure SignalR Service

I'm implementing Azure SignalR service in my ASP.NET Core 2.1 app with React front-end. When I send a message, I'm not getting any errors but my messages are not reaching the Azure SignalR service. To be specific, this is a private chat application so when a message reaches the hub, I only need to s...
Sam
4

votes
1

answer
2.4k

Views

How to pass some data through signalR header or query string in .net core 2.0 app

Using signalR in .net 4.7 we were able to pass two variables from the client application to signalR server. Here is the code snippet: public class MyHub : Hub { protected (string myVar1, string myVar2) GetValues() => ( Context.QueryString["MyVariable1"] ?? string.Empty, Context.QueryString["MyVariab...
Arash
3

votes
1

answer
1.9k

Views

How to authorize SignalR Core Hub method with JWT

I am using JWT authentication in my ASP.NET Core 2.0 application with OpenIddict. I am following idea in this thread and calling AuthorizeWithJWT method after SignalR handshake. But now, I do not know what should I set in AuthorizeWithJWT method so I can use [Authorize(Roles="Admin")] for example....
Makla
2

votes
1

answer
598

Views

SignalR Core not using Websockets in Azure App Service

I'm working on a SignalR Core web app that uses the following stack: ASP.NET Core 2.1 preview 2 (2.1.0-preview2-final) SignalR Core 1.0 preview 2 (1.0.0-preview2-final) Microsoft.AspNetCore.Cors (2.1.0-preview2-final) Microsoft.AspNetCore.WebSockets (2.1.0-preview2-final) The client is using SignalR...
Matias Quaranta
3

votes
2

answer
426

Views

How to use signalr on flutter?

Hi guys I`m trying to communicates with and aspnet core 2.1 application that uses signalr to establish its chat communications, but i cant figure it out whats the best way to accomplish that using flutter. I've searched for some lib to do it, but the one that I founded is not compatible with flutte...
Diego Garcia
2

votes
1

answer
1.3k

Views

SignalR Client in Xamarin

I am trying to add the SignalR client to a Xamarin.Forms project. I see that there are 2 packages, one for .Net and the other for .NetCore Microsoft.AspNet.SignalR.Client and Microsoft.AspNetCore.SignalR.Client The project that I am adding it to is a .Net Standard 2 project But whenever I run the a...
2

votes
1

answer
410

Views

connection.closed is not a function SignalR

I'm confused about the closed event in SignalR. Apparently, there was some debate about what to call it e.g. onClosed(), closed(), etc. In my SignalR listener on the client side, I'm trying to implement this event but I keep getting an error that says it's not a function. I tried onClosed() and clos...
Sam
0

votes
0

answer
2

Views

Can't negotiate handshake from Angular to Azure SignalR (.NET CORE host)

I'm trying to change from local SignalR service on .NET CORE 2.1 back-end to Azure SignalR. All: Angular (@aspnet/signalr), SignalR and Azure SignalR packages in v1.0.4. At local configuration everything works great. services.AddCors(options => { options.AddPolicy("AllowAll", builder => builder.Allo...
Triti
5

votes
1

answer
2k

Views

SignalR version compatability (StatusCode: 405 'Method Not Allowed')

I'm having issues with a SignalR project I'm currently working on. I'm trying to build a server using .Net Core, and a client using traditional .Net (framework 4.6.1). However the server and client don't seem to be compatible. The last issue I've run into is a StatusCode: 405, ReasonPhrase: 'Method...
Louis Somers
4

votes
1

answer
590

Views

SignalR testing - how to mock groups in new version of SignalR for ASP.NET Core 2

I try to write test for my Hub method, but I don't know as because there is no documentation or code examples for current (1.0.0-alpha2-final) version of SignalR. There is my code: [Fact] public void SaveVisitorInfoTest() { //Arrange var chatHub = new ChatHub(); var mockClients = new Mock(); chat...
Vladimir Sharp
3

votes
0

answer
736

Views

Can SignalR for ASP.NET Core be self hosted in a Windows exe or a Xamarin app?

MS recently released an alpha build of SignalR for ASP.NET Core 2.0. I can't see any doco about whether it can be self hosted in a windows service, which earlier versions of SignalR supported. Also is it possible to have self hosted in a Xamarin app? Imagine a Xamarin app that is basically a wrappe...
Jeff - Software Results
3

votes
1

answer
588

Views

How to enable Windows Authentication in AspNetCore SignalR Alpha

How do I configure SignalR to Authenticate/Authorize to a server that is must be protected by Windows Authentication. There appears to be no way to make the JavaScript Client send Credentials with the request.
H. D. H.
8

votes
0

answer
364

Views

Client Lifecycle events in ASP.NET Core SignalR

I'm currently upgrading a project from ASP.NET SignalR 2.2.3 (OWIN) to ASP.NET Core SignalR 1.0.2 (Kestrel). SignalR 2.2.3 supported several client sided lifetime events like reconnecting, connectionSlow, stateChanged, ... . Our javascript client used those events and displayed something like "Recon...
Robar
3

votes
1

answer
1.9k

Views

AspNetCore.SignalR : Cannot start a connection that is not in the Initial state

I have troubles to get my ASP.NET Core SignalR app working. I have this server-side code : public class PopcornHub : Hub { private int Users; public async Task BroadcastNumberOfUsers(int nbUser) { await Clients.All.InvokeAsync("OnUserConnected", nbUser); } public override async Task OnConnectedAsyn...
Ben
3

votes
1

answer
570

Views

Difference between SendAsync and SendCoreAsync methods in SignalR Core?

When updating to the latest version of ASP Net Core and SignalR core, I noticed their are two "send" methods available when sending methods to a client (what used to be InvokeAsync). After looking at the code comments, both methods are identical in comments, both inherit from IClientProxy, and both...
FasettoAndy
3

votes
3

answer
245

Views

Call Signalr method from Controller .Net Core 2.1

I am trying to call a method in the signalr Hub class from an (ASP.NET Core) MVC Controller, but I cannot find an example online that shows how to. Note: There are lots of examples using older versions of signalr with the .Net Framework, but none that I can see that show how to do this in .Net Core....
Brett Rigby
1

votes
1

answer
842

Views

Error 204 when trying to connect to SignalR

I'm not able to connect to my SignalR Hub in a ASP.NET Core 2.0.3 application running under Windows 7. I'm using SignalR 1.0.0-alpha1-final from NuGet as server and the signalr-client-1.0.0-alpha2-final.min.js as JavaScript client. Here is my hub: using System; using System.Threading.Tasks; using Mi...
Mark
1

votes
1

answer
786

Views

Detect lost connection from SignalR Core connection

I'm trying to detect when a SignalR Core connection is lost, so that I can create a new one or at least warn the user. connection.on('closed', data => { alert('Connection Closed'); }); This seems to have no effect. The messages stop arriving but this handler isn't fired. On a related note, where is...
Ian Warburton
1

votes
1

answer
949

Views

Initializing HubConnection from TestServer in ASP.NET Core SignalR

Is is possible to initialize HubConnection from Microsoft.AspNetCore.TestHost.TestServer? The example below throws HttpRequestException(Not Found) exception at await hubConnection.StartAsync(); using System; using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting...
idubnori
2

votes
1

answer
1.3k

Views

SignalR call client methods from outside the Hub class AspNetCore

I'm trying to call client methods outside the hub on SignalR, the link below shows how to do this in the old version, although i'm unsure how to do this in the SignalR ASP.NET Core version. I've found a reference to a old post and using a reference to Microsoft.AspNetCore.SignalR.Infrastructure.ICon...
John
2

votes
3

answer
813

Views

Disconnect client from IHubContext<THub>

I can call InvokeAsync from server code using the IHubContext interface, but sometimes I want to force these clients to disconnect. So, is there any way to disconnect clients from server code that references the IHubContext interface?
Carlos Beppler
2

votes
1

answer
2.2k

Views

signalr unity3d connection

I am fairly new to signalr. Im using signalr core to make connection between unity and signalr but my code doesn't return me anything at all. That leaving me wondering if my code is actually working or not. After I've established connection, unity will wait for server side to call a function then it...
kim
4

votes
1

answer
1.2k

Views

SignalR Dependency Injection for ASP.NET Core v2.0 using Autofac

Is it possible to use dependency injection to inject dependencies into SignalR on ASP.NET Core v2.0? Assuming the following hub and dependency: public MyHub : Hub { private readonly IMyDependency dependency; public MyHub(IMyDependency dependency) { this.dependency = dependency; } } public void MyDep...
Luke
6

votes
2

answer
1.1k

Views

ASP.NET CORE 2.1 Server timeout while debugging

'Error: Server timeout elapsed without receiving a message from the server.'. I'm trying to debug some server-side code and while I do that the client gets disconnected in less than a minute. I'm only using SignalR to communicate to clients, without controllers yet. Is there any setting that can dis...
Arhire Ionut
2

votes
1

answer
983

Views

AspNet.Core, IdentityServer 4: Unauthorized (401) during websocket handshake with SignalR 1.0 using JWT bearer token

I have two aspnet.core services. One for IdentityServer 4, and one for the API used by Angular4+ clients. The SignalR hub runs on the API. The whole solution runs on docker but that should not matter (see below). I use implicit auth flow which works flawlessly. The NG app redirects to the login page...
Daniel Leiszen
5

votes
2

answer
2.9k

Views

Get Hub Context in SignalR Core from within another object

I am using Microsoft.AspNetCore.SignalR (latest release) and would like to get the hub context from within another object that's not a Controller. In the "full" SignalR, I could use GlobalHost.ConnectionManager.GetHubContext(); I have seen a lot of examples of just adding Microsoft.AspNetCore.Signal...
Andy
2

votes
1

answer
774

Views

Angular 5.1.1 infinite refresh loop after set proxy for signalr?

I'm working with Angular 5.1.1 and @angular/cli ^1.6.1. I want to use Asp.Net Core SignalR. So I have the following proxy setting: const PROXY_CONFIG = [ { context: [ "/api", "/Temp", "/Upload", "/notificationHub", "/sockjs-node" ], target: "http://localhost:52918/", changeOrigin: true, secure: fals...
Mohammad Dayyan
3

votes
0

answer
34

Views

How to enable Cors in Signalr Azure Service

I am trying to use the Azure SignalR Service in a web app that only contains a hub class. When I try to access from another domain to the hub I get the following error "Access to XMLHttpRequest at 'https://*/genericSocketHub/negotiate' from origin 'https://localhost:44303' has been blocked by CORS...
Joel Egusquiza
2

votes
1

answer
868

Views

How to invoke SignalR Clients.All.InvokeAsync() in places other than the Controller?

I'm able to access my IHubContext fine and dandy in my .NET Core WebAPI's Controller through DI in the constructor, but I want to access it elsewhere too. Specifically, when I consume a message from RabbitMQ, sometimes I want to update clients through _myHubContext.Clients.All.InvokeAsync(), but I j...
Nickdb93
3

votes
3

answer
2.8k

Views

.Net Core SignalR - connection timeout - heartbeat timer - connection state change handling

just to be clear up-front, this questions is about .Net Core SignalR, not the previous version. The new SignalR has an issue with WebSockets behind IIS (I can't get them to work on Chrome/Win7/IIS express). So instead I'm using Server Sent Events (SSE). However, the problem is that those time out af...
ExternalUse

View additional questions