signalr

Context.User is null in a Signalr 2.0 Hub

浪尽此生 提交于 2019-12-19 08:01:52
问题 I'm using VS 2013 Express and the standard MVC5 template to create a new clean app. Authentication is enabled and I can log into the site just fine. I can see the user context in my controllers, but when I add Signalr I can't get the Hubs to register that authentication has take place. Context.User in the hub is null. Using Signalr 2.0.2 and all related OWIN packages. 回答1: The resolution to the program was very simple. In my startup class I had the code in the wrong order. This is what I had

/signalr/hubs 404 not found after update to MVC5

故事扮演 提交于 2019-12-19 07:16:10
问题 SignalR was working while project was ASP.NET MVC3. Now i upgraded it to MVC5 (not so easy to do, I must tell you). Then I noticed that signalR was not working. I went by the book, reinstalled SignalR to version 2.1.0, installed OWIN (must-have for v2+) and added startup class to project. This is my startup.cs class, it sits at project root folder: [assembly: OwinStartup(typeof(SISTEM.Startup))] namespace SISTEM { public class Startup { public void Configuration(IAppBuilder app) { app

Sending async mail from SignalR hub

限于喜欢 提交于 2019-12-19 03:24:26
问题 I need to send an email as a result of a SignalR hub invocation. I don't want the send to execute synchronously, as I don't want to tie up WebSocket connections, but I would like the caller to be informed, if possible, if there were any errors. I thought I'd be able to use something like this in the hub (minus error handling and all other things that I want it to do): public class MyHub : Hub { public async Task DoSomething() { var client = new SmtpClient(); var message = new MailMessage(/*

SignalR scaling out with Azure EventHub

回眸只為那壹抹淺笑 提交于 2019-12-19 00:24:20
问题 I am looking high frequency scaling solution for SignalR. I am wondering if I can do it with Azure EventHub. If I use EventHub as my backplane for SignalR messages, will it become a bottleneck for me? I've checked this page but there is nothing about EventHub as it is fairly new. 回答1: I can't speak to the precise specifics of SignalR; however, you could in principle use EventHubs for a backplane, but you need to be aware of the limitations. SignalR's backplane scaleout pattern assumes that

SignalR, Owin and exception handling

泄露秘密 提交于 2019-12-18 19:03:06
问题 I've developed a sample SignalR application based on ASP.NET 4.5 & Owin, and I've hosted that app on IIS 7.5. Everything is working fine, but how can I handle exceptions in Owin? Consider the following code: [HubName("SampleHub")] public class SampleHub : Hub { public SampleHub() { throw new InvalidOperationException("?!"); } } This exception won't call Application_Error (and this is my problem). Where can I get all exceptions from Owin for logging and debugging purposes similarly to

SignalR long-polling is disconnected in 5 seconds

北慕城南 提交于 2019-12-18 17:37:11
问题 My application is working under corporate network (ugly proxies and stuff). And it does not work very well. I hoped using https would help but it did not. Here is a weird pattern I see in the logs: [14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Client subscribed to hub 'modemshub'. [14:13:32 GMT+0600 (N. Central Asia Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.5&connectionToken=6aktO0sramoQKhQ9DC7Cs7EbXMUou8LooQRxfup4R0oZCHpBmWBFjyLup

Is there a way to get number of connections in Signalr hub group?

主宰稳场 提交于 2019-12-18 16:48:31
问题 Here is my problem, I want to track if user is online or offline and notify other clients about it. I'm using hubs and implemented both IConnected and IDisconnect interfaces. My idea was to send notification to all clients when hub detects connect or disconnect. By default when user refreshes page he will get new connection id and eventually previous connection will call disconnect notifying other clients user is offline even though he's actually online. I tried to use my own

SignalR: Detecting Alive Connection in C# clients

旧巷老猫 提交于 2019-12-18 14:52:42
问题 I am currently developing an application using SignalR (2.1) Hubs. I have 1 WPF client and the other is a WCF client. Everything works fine in that they are passing the messages perfectly. The only problem I faced now is that I noticed the OnDisconnected is not fired at all when the application shuts down for reasons such as auto-restarts, WCF server went down and a few others. The timeout is the default of 30 seconds. It is never called even after 1 day has passed (I tried). However, the

Unified static class between HttpContext and SignalR HubCallerContext

南楼画角 提交于 2019-12-18 14:48:11
问题 I have a lot of code that depends on HttpContext.Current, and I noticed that requests that come from SignalR hubs have HttpContext.Current == null , so my code breaks, for example: HttpContext.Current.Request.IsAuthenticated So I came up with following: public static class UnifiedHttpContext { private static HubCallerContext SignalRContext { get; set; } private static int SignalRUserId { get { return WebSecurity.GetUserId(SignalRContext.User.Identity.Name); } } private static bool

How does SignalR decide which transport method to be used?

早过忘川 提交于 2019-12-18 14:43:09
问题 SignalR is an abstraction over transports used for real-time connections. Still I'd like to know how exactly it decides which transport methods should be used, depending on various factors. I did some research using available documentation and looked into sources and came up with an idea how it works. So my actual question would be, is the following flowchart correct or am I missing anything? Update : Thanks for your input! Here is an updated version according to your fixes. But I'm still not