asp.net-core-signalr

Detect lost connection from SignalR Core connection

北战南征 提交于 2019-12-23 12:43:37
问题 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 the documentation for event handling for the new version of this library? 回答1: Use onclose : connection.onclose(function (e) { alert('Connection Closed'); } There's no documentation yet, but a

Access SignalR Hub without Constructor Injection

落爺英雄遲暮 提交于 2019-12-23 04:01:27
问题 With AspNetCore.SignalR (1.0.0 preview1-final) and AspNetCore.All (2.0.6), how can I invoke a method on a hub in server code that is not directly in a Controller and is in a class that cannot be made via Dependency Injection? Most examples assume the server code is in a Controller and should 'ask' for the hub via an injectable parameter in a class that will created by DI. I want to be able to call the hub's method from server code at any time, in code that is not injected. The old SignalR had

Access SignalR Hub without Constructor Injection

巧了我就是萌 提交于 2019-12-23 04:01:05
问题 With AspNetCore.SignalR (1.0.0 preview1-final) and AspNetCore.All (2.0.6), how can I invoke a method on a hub in server code that is not directly in a Controller and is in a class that cannot be made via Dependency Injection? Most examples assume the server code is in a Controller and should 'ask' for the hub via an injectable parameter in a class that will created by DI. I want to be able to call the hub's method from server code at any time, in code that is not injected. The old SignalR had

Passing JWT Token as QueryString to SignalR Hub

会有一股神秘感。 提交于 2019-12-22 18:40:29
问题 Trying to follow the suggestions in the link below to pass a JWT token to my SignalR hub but so far it's not working. In particular, see David Fowler's suggestion on July 22, 2017. https://github.com/aspnet/SignalR/issues/130 My frontend is React so I'm simply adding the token to the querystring as follows where _token has my JWT token value: const connection = new signalR.HubConnectionBuilder() .withUrl("/myhub?AUTHORIZATION=" + _token) .configureLogging(signalR.LogLevel.Information) .build(

React Native app won't complete negotiation with SignalR Core

↘锁芯ラ 提交于 2019-12-22 18:19:45
问题 I'm trying to integrate the SignalR Core JS client on React Native but can't quite seem to get it to work with a ASP.NET Core server with SignalR. I've heard that other people have been able to make it work despite the lack of a designated React Native client. I keep getting the following error: "Error: Failed to complete negotiation with the server: Error". Could someone help me? Here's what the React Native app looks like: App.js import React, { Component } from 'react'; import { Platform,

Issue with SignalR core and cross domain requests

余生颓废 提交于 2019-12-22 10:43:52
问题 We are using SignalR core with CORS cross domain requests. The client is unable to connect to server. 401 Unauthorized No Access-Control-Allow-Origin' header is present on the requested resource. Error: Failed to start the connection. Note we are using the most recent signalr core (alpha version for asp.net core 2.0). Please note within the same client app, i'm able to access CORS Web API methods. It's isolated to SignalR hub/client. We are using Windows authentication in IIS. Anonymous seems

Call Signalr method from Controller .Net Core 2.1

让人想犯罪 __ 提交于 2019-12-22 09:28:36
问题 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. I need to pass an id from the an MVC Action Result directly through to my Hub, without passing the id to the page, and then having to get a client connection back through to the hub. public class

How can I pass a SignalR hub context to a Hangfire job on ASP .NET Core 2.1?

ぐ巨炮叔叔 提交于 2019-12-21 05:22:32
问题 How can I pass a SignalR hub context to a Hangfire job on ASP .NET Core 2.1? It seems that since passing arguments to Hangfire is done via serialization/deserialization, it seems that Hangfire has hard-time reconstructing the SignalR hub context. I schedule the job (in my controller) using : BackgroundJob.Schedule(() => _hubContext.Clients.All.SendAsync( "MyMessage", "MyMessageContent", System.Threading.CancellationToken.None), TimeSpan.FromMinutes(2)); Then after 2 minutes, when the job

signalr unity3d connection

我只是一个虾纸丫 提交于 2019-12-20 14:39:13
问题 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 will execute what it need to do. here is my code : using System.Collections; using System.Collections.Generic; using UnityEngine; using Microsoft.AspNetCore.SignalR.Client; public class

Connection ID when calling SignalR Core Hub method from Controller

百般思念 提交于 2019-12-20 02:35:35
问题 This is a follow-up to another question and answer. What's the effect of calling HubContext.Clients.Caller or HubContext.Clients.Others from the controller? I see it depends on the connection ID. What value would it have in this situation? If the connection ID (and thus Caller and Others ) is invalid then (from within the controller action) how could I obtain a connection ID (for the client currently calling the Web API) that I could use with HubContext.Clients 's methods? 回答1: What's the