signalr

Web Performance Test: SignalR - Unrecognized user identity

半世苍凉 提交于 2019-12-25 02:37:10
问题 When running a recorded Web Test using Visual Studio, initializing the signalr connection triggers the error. Unrecognized user identity. The user identity cannot change during an active SignalR connection. Request: GET /Computer/signalr/connect? transport=foreverFrame& connectionToken=xxx& connectionData=yyy& tid=7& frameId=1 HTTP/1.1 User-Agent : Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) Accept : */* Accept-Language : en-GB Accept-Encoding : GZIP Host : test.host.com

How can I make a server time app with SignalR

一曲冷凌霜 提交于 2019-12-25 01:23:16
问题 I'm leaning SignalR. How can I write a simple app so user can see server-time in real-time using Hub. Every 1 second, server will send time from server to connected clients 回答1: you can do when you using thread. Example Hub Class: public class ServerTime : Hub { public void Start() { Thread thread = new Thread(Write); thread.Start(); } public void Write() { while (true) { Clients.settime(DateTime.Now.ToString()); Thread.Sleep(1000); } } } Example Script : <script type="text/javascript"> $

SignalR “Access to XMLHttpRequest …” error in ASP.NET MVC

亡梦爱人 提交于 2019-12-25 01:22:58
问题 I use SignalR ( Microsoft.AspNet.SignalR .SystemWeb v2.4.0 and Microsoft.AspNet.SignalR.Core v2.4.1.0 ) in an ASP.NET MVC application and when debugging, I encounter "Access to XMLHttpRequest at 'https://demo.com/signalr/negotiate?clientProtocol=2.1&connectionData=%5B%7B%22name%22%3A%22demohub%22%7D%5D&_=1569323349167' from origin 'http://localhost:20700' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." error. By looking on the

How to Make SignalR connection establishment When Login in Asp.net core 2.1 & Angular 6

拟墨画扇 提交于 2019-12-25 01:05:14
问题 I want to make SignalR connection establishment when login to system,now it's doing separately.In .net core I used Microsoft.AspNetCore.SignalR package and in angular I used @aspnet/signalr .When user connect with signalR,then that user want to store in a list with connectionId and username. Here is my login method in client side login(model: any) { return this.http.post(this.baseUrl + 'login', model).pipe( map((response: any) => { const user = response; if (user) { localStorage.setItem(

SignalR Javascript Client Error: Dynamic file not generated

南楼画角 提交于 2019-12-24 23:01:26
问题 Here is the screenshot of runtime project that contains signalR. There is no hubs file generated. I am getting the most common javascript error That is also shown in picture. I searched and found many solutions but nothing seems to work. like changing reference src and etc. Here is how I am referencing the script files. <script src="Scripts/jquery-3.3.1.min.js"></script> <!--Reference the SignalR library. --> <script src="Scripts/jquery.signalR-2.2.2.min.js"></script> <!--Reference the

Filtering Data Table inside Hub Class PREVENTS SQL Dependency to run

旧城冷巷雨未停 提交于 2019-12-24 21:18:39
问题 I am using SignalR and SQL dependency to deliver real time data based on a SQL Server query with parameter related to the user connectionId. I have a strange problem related to SQL depedency: I am sending a userid through query string to the hub. For each hub start, I am saving the connection Id and that userId in SQL Server database and my SQL query which I am linking to SQL dependency has filter related to the connectionId. I tried to include the filter based on that connectionId in the

《ASP.NET SignalR系列》第三课 SignalR的支持平台

我的未来我决定 提交于 2019-12-24 20:22:13
从现在开始相关文章请到: http://lko2o.com/moon 接续上一篇: 《ASP.NET SignalR系列》第一课 认识SignalR (还没有看的话,建议您先看看) 一、指定通信方式 建立一个通讯方式需要一定的时间和客户机/服务器资源。如果客户机的功能是已知的,那么通信方式在客户端连接开始的时候就可以指定。下面的代码片段演示了使用AJAX长轮询方式来启动一个连接,将如果我们知道该客户端不支持其他的协议的话: connection . start ({ transport : 'longPolling' }); 你可以指定一个替补方式,如果你想让客户端按照顺序尝试通讯方式的话.下面的代码片段展示了尝试使用WebSocket,如果失败直接使用长轮询。 connection . start ({ transport : [ 'webSockets' , 'longPolling' ] }); 指定将字符串常量定义如下: webSockets foreverFrame serverSentEvents longPolling 二、连接和集线器(Hubs) SignalR API包括两种模型(用于客户端和服务端的通信):持久连接模型(Persistent Connections)和集线器(Hubs)模型    一个连接 代表一个简单的终结点(相当于单个收件人、被分组的

Best use of SignalR Hub

青春壹個敷衍的年華 提交于 2019-12-24 19:51:44
问题 In my app, I have different parts, like Products, People, Suppliers, etc that they are entities which I defined as a Table in Db, and each part has separated page and its own logic for instant client update according to the Database changes. Also, I have some general rules for sending messages to Users and Groups. In this application, users can chat with them. However, I really can't decide how should I implement these in my application? How many hubs do I need? Single hub and different

Iterate through groups in signalR hub class

笑着哭i 提交于 2019-12-24 19:25:15
问题 How can I iterate through a SignalR group (hub class) Groups.Add(Context.ConnectionId, "foo"); How would I iterate through the group to see whose in it? and then possibly based on the connectionId in there return a user 回答1: From the SignalR docs: Groups are not persisted on the server so applications are responsible for keeping track of what connections are in what groups so things like group count can be achieved. So no, you can't iterate over the users in a group, you need to keep track of

How Can I get UserId from ConnectionId in asp.net identity framework SignalR?

雨燕双飞 提交于 2019-12-24 17:43:30
问题 I am using Asp.net Identity framework for authentication. Now I need the User id of connected client from connectionId or role of connected user. 回答1: public class WhateverHub : Hub { public override Task OnConnected() { //Get the username string name = Context.User.Identity.Name; //Get the UserId var claimsIdentity = Context.User.Identity as ClaimsIdentity; if (claimsIdentity != null) { // the principal identity is a claims identity. // now we need to find the NameIdentifier claim var