signalr-hub

Can I reduce the Circular Buffer to “1”? Is that a good idea?

匆匆过客 提交于 2019-12-06 05:39:44
问题 By default, there are a default of 1,000 messages stored in the ring buffer on the server. It doesn't make sense for me to send a lagging client 1,000 updates, but rather just the most recent update. In WCF I can do this by using volatile data. I suppose I can emulate a volatile approach by reducing the buffer to "1", but not sure if this can be configured on a per hub basis, or ideally, on a per method basis. Does it matter if I use hubs or persistent connections with this? 回答1: Even if you

SignalR Groups.Add times out and fails

泄露秘密 提交于 2019-12-06 01:48:18
I'm trying to add a member to a Group using SignalR 2.2. Every single time, I hit a 30 second timeout and get a "System.Threading.Tasks.TaskCanceledException: A task was canceled." error. From a GroupSubscriptionController that I've written, I'm calling: var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProjectHub>(); await hubContext.Groups.Add(connectionId, groupName); I've found this issue where people are periodically encountering this, but it happens to me every single time. I'm running the backend (ASP.NET 4.5) on one VS2015 launched localhost port, and the frontend (AngularJS

Is it possible to return a pre-encoded JSON string in a SignalR hub method?

我是研究僧i 提交于 2019-12-06 00:47:14
In an MVC project, I have a method on a hub similar to this: public string Foo() { return DoCrazyThingThatReturnsJson(); } Unfortunately SignalR (or something) takes the encoded JSON string and happily encodes it, then returns it, so browser be like LOLWTF. Is there a way to skip this second encoding? Looking at this here : We assume that any ArraySegment is already JSON serialized it seems like something like this may work (note that I haven't tried it, so no promises): string jsonString = ...; // your serialized data var jsonBytes = new ArraySegment<byte>(Encoding.UTF8.GetBytes(jsonString));

SignalR - How to perform async Task in hub?

痴心易碎 提交于 2019-12-05 23:19:55
问题 I am trying to create a SignalR application using the C# 5 async/await features, but whenever the code is run, it will throw an System.InvalidOperationException. Here is the simplest code to reproduce the problem. public class SampleHub : Hub { public Task<string> GetGoogle() { var http = new WebClient(); return http.DownloadStringTaskAsync("http://www.google.com"); } } Exception details: An asynchronous operation cannot be started at this time. Asynchronous operations may only be started

SignalR: Error loading hubs

前提是你 提交于 2019-12-05 18:13:29
问题 Signalr doesn't load my hubs: SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. <script src='/signalr/js'></script>. I am calling app.MapSignalR(); in startup configuration . I added to my cshtml: <script src="~/Scripts/jquery-1.9.1.js"></script> <script src="~/Scripts/jquery.signalR-2.0.0.js"></script> <script src="~/signalr/hubs" type="text/javascript"></script> <script> $(document).ready(function () { window.hubReady = $.connection.hub.start(); }); </script> 回答1:

SignalR 2 long polling “protocol” request times out when not ran locally

家住魔仙堡 提交于 2019-12-05 17:45:51
Currently I have an app that is very chatty and needs to be supported by a Singleton(See Code below). I upgraded to SignalR 2.0 and I followed the upgrade guide, but after I deploy it out to an environment, sometimes all requests for every "protocol" fail, and signalr breaks, and when it doesn't break then it is terribly slow to push notifications down to the client from the server, Maybe this has something to do with it using long polling? Here is what my server side code looks like. Configuration Method in Owin Start up class var hubConfig = new HubConfiguration(); hubConfig

SignalR overwriting OnConnected(), OnDisconnected()

天涯浪子 提交于 2019-12-05 16:54:25
问题 I'm trying to overwrite OnConnected() , OnDisconnected() methods but I get: OnConnected()': no suitable method found to override Is implementing IDisconnect , IConnect interfaces and doing my processing within Connect() and Disconnect() the same as OnConnected() , OnDisconnected() ? what gives? public static class UserHandler { public static HashSet<string> ConnectedIds = new HashSet<string>(); } public class MyHub : Hub { public override Task OnConnected() { UserHandler.ConnectedIds.Add

SignalR request pipeline, Hub lifetime

时光总嘲笑我的痴心妄想 提交于 2019-12-05 12:28:15
I am starting on signalR with asp.net webapi, and I am trying to understand the whole signalR request/connection pipeline and what is the lifetime of the hub and who creates and dispose the hub instance (does it gets created on every communication between client and server?) One of the reason is that we need to understand how we should be using an IoC contain in signalR request scenario, how we control the lifetime of the dependency correct specifically the ISession or DBContext . Hubs instances are created at every single request from a client. They are not kept around, therefore you should

calling the Caller method in SignalR hub outside the hub context

╄→尐↘猪︶ㄣ 提交于 2019-12-05 09:31:28
I have a question in my mind about the Caller method of SignalR. In the hub method we can call a client side function like this. Clients.Caller.addContosoChatMessageToPage(name, message); but when i use to call it from outside the hub context it is not found or not implemented?? like this.. var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); context.Clients.Caller.reportProgress(recordCount,totalCount); Can someone enlighten me in this part or is there other way to implement it.. by now i use to implement this var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();

SignalR cannot connect to Azure Redis on SSL

假装没事ソ 提交于 2019-12-05 06:29:39
I am currently hosting my redis cache server on Azure, and have signalR relying on it as the backbone using the following... GlobalHost.DependencyResolver.UseRedis("Server",port,"password","eventKey"); This works find on port 6379 (non-SSL) but my chat app breaks when I try to connect to the SSL port (6380) of my Azure Redis server, and the hub is never started. What could be the cause of this issue? Or am I doing something wrong? This is the error that appears on /signalr/connect in my browser net::ERR_CONNECTION_RESET You can try this: GlobalHost.DependencyResolver.UseRedis(new