天道酬勤,学无止境

asp.net-core-signalr

ASP.NETCore Signalr not work on AWS

We have two applications, server-side (.Net Core 2.0) and client side (AngulerJs) that they are hosted on AWS elistic container service, also, there is a layer of cloud flare, in addition, we are using an ALB that is pointing to our docker containers. Our solution should have a real time services which pushs data to the client side, so we used asp net core signalr version = "1.0.0-alpha2-final" for this purpose. The problem is, the signalr is working fine when we test it in localhost but when host the applications in the AWS it works for 1 minute or so and then it throw error: "Websocket

2021-06-15 08:13:06    分类:问答    amazon-web-services   .net-core   asp.net-core-signalr

React Native app won't complete negotiation with SignalR Core

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, StyleSheet, Text, View, TouchableHighlight, TextInput, Alert } from 'react-native'; import * as signalR

2021-06-10 21:43:52    分类:问答    react-native   asp.net-core   asp.net-core-signalr

Using SignalR Core to send messages from a Controller Method to Angular

I'm trying to use SignalR for Asp Net Core 2.1 in order to send a message from a controller method which call is triggered from a test button in Angular. The behavior I'd expect is that when I click the button, my service invokes the controller method, which sends the test message. Then, I will simply log the message. I want to manage this in a service in order to avoid code duplication in all of the components. I've read some examples like this question about using SignalR in a service (I've used the second solution) and this article and the official docs but even with applying these concepts

2021-06-05 22:29:41    分类:问答    c#   angular   asp.net-core   signalr   asp.net-core-signalr

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 disable timeout or at least make it way longer than it is now? my launchSettings.json: { "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:26793", "sslPort": 44386 } }, "profiles": { "IIS Express": { "commandName":

2021-06-04 23:37:05    分类:问答    asp.net-core   asp.net-core-signalr

从控制器调用 SignalR Core Hub 方法(Call SignalR Core Hub method from Controller)

问题 如何从 Controller 调用 SignalR Core Hub 方法? 我将 ASP.NET Core 2.0 与 Microsoft.AspNetCore.SignalR (1.0.0-alpha2-final) 一起使用。 我有与 Excel、SolidEdge 通信的 Windows 服务......操作完成后,它会在 ASP.NET Core 应用程序中向我的控制器发送请求。 现在我需要用 SignalR 通知所有连接到服务器的客户端外部程序完成了一些任务。 我无法改变窗口服务的工作方式。 (无法从窗口服务连接到 SignalR)。 我发现老SignalR(大量的解决方案GlobalHost.ConnectionManager.GetHubContext ),但大部分已经改变,这些解决方案都不能工作了。 我的控制器: [Route("API/vardesigncomm")] public class VarDesignCommController : Controller { [HttpPut("ProcessVarDesignCommResponse/{id}")] public async Task<IActionResult> ProcessVarDesignCommResponse(int id) { //call method

2021-06-01 19:45:17    分类:技术分享    c#   signalr   asp.net-core-2.0   asp.net-core-signalr

In ASP.NET Core SignalR, how do I send a message from the server to a client?

I've successfully setup a SignalR server and client using the newly released ASP.NET Core 2.1. I built a chat room by making my ChatHub extend Hub: whenever a message comes in from a client, the server blasts it back out via Clients.Others. What I do not yet understand is how to send a message to clients not as a response to an incoming message. If the server is doing work and produces a result, how do I gain access to the Hub in order to message particular clients? (Or do I even need access to the Hub? Is there another way to send messages?) Searching this issue is difficult as most results

2021-06-01 07:45:01    分类:问答    c#   asp.net-core   asp.net-core-signalr

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

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 tries to execute, I have the error : Newtonsoft.Json.JsonSerializationException: Could not create an

2021-05-31 15:04:04    分类:问答    c#   asp.net-core   signalr   hangfire   asp.net-core-signalr

How to send Parameter/Query in HubConnection SignalR Core

I'm trying to add parameter into connection to signalr. I'm using Builder to create my Client connection and start it: var connection = new HubConnectionBuilder() .WithUrl("http://10.0.2.162:5002/connection") .WithConsoleLogger() .WithMessagePackProtocol() .WithTransport(TransportType.WebSockets) .Build(); await connection.StartAsync(); I want to send a simple parameter in this connection: Something Like: "Token": "123" In my server side i think i can take this parameter from HttpContext: public override Task OnConnectedAsync() { var httpContext = Context.Connection.GetHttpContext(); var token

2021-05-24 12:39:09    分类:问答    c#   signalr-hub   asp.net-core-signalr

How to get the AspNet Core SignalR Transport Protocol in the Hub?

In the old SignalR, you could do this to get the transport in the Hub on the Server: Context.QueryString["transport"]; But in the new SignalR, written for AspNet Core, I couldn't find where the Transport Protocol can be found within the Hub on the Server. Can it be found? If so, where?

2021-05-12 14:44:54    分类:问答    signalr   asp.net-core-signalr

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. I tried with setting context user, but it is readonly: public class BaseHub : Hub { public async Task AuthorizeWithJWT(string AccessToken) { //get user claims from AccesToken this.Context.User = user; //error User is read only } } And using authorize attribute: public class VarDesignImportHub

2021-05-09 03:36:31    分类:问答    authentication   signalr   openiddict   asp.net-core-signalr