Questions tagged [signalr-hub]

Hubs provide a higher level RPC framework over a PersistentConnection. If you have different types of messages that you want to send between server and client then hubs is recommended so you don't have to do your own dispatching.

For a complete specification check out the SignalR Hubs Wiki page.

1597 questions
280
votes
4 answers

.net localhost website consistently making get arterySignalR/poll?transport=longPolling&connectionToken= calls

I created a new VS 2013 project and viewed the default.aspx page with the Firefox browser. When I check the net calls it has made, I see it making constant calls…
user2981059
  • 2,801
  • 2
  • 12
  • 3
93
votes
5 answers

Best practice for reconnecting SignalR 2.0 .NET client to server hub

I'm using SignalR 2.0 with the .NET client in a mobile application which needs to handle various types of disconnects. Sometimes the SignalR client reconnects automatically - and sometimes it has to be reconnected directly by calling…
Ender2050
  • 6,912
  • 12
  • 51
  • 55
85
votes
2 answers

How to use SignalR hub instance outside of the hubpipleline

I am using SignalR to broadcast messages to all my clients. I need to trigger the broadcasting outside of my hub class i.e. something like below: var broadcast = new chatHub(); broadcast.Send("Admin","stop the chat"); I am getting error message…
Nitin Agrawal
  • 1,341
  • 1
  • 10
  • 19
73
votes
5 answers

Calling SignalR hub clients from elsewhere in system

I've set up a SignalR hub to communicate between the server and client. The hub server side code is stored in a class called Hooking.cs. What I want is to be able to call a method defined in Hooking.cs to allow me to broadcast messages to any…
Jordan Wallwork
  • 3,116
  • 2
  • 24
  • 49
66
votes
5 answers

SignalR + posting a message to a Hub via an action method

I am using the hub- feature of SignalR (https://github.com/SignalR/SignalR) to publish messages to all subscribed clients: public class NewsFeedHub : Hub public void Send(string channel, string content) { …
ollifant
  • 8,576
  • 10
  • 35
  • 45
65
votes
6 answers

Get number of listeners, clients connected to SignalR hub

Is there a way to find out the number of listeners (clients connected to a hub?) I'm trying to run/start a task if at least one client is connected, otherwise do not start it: [HubName("taskActionStatus")] public class TaskActionStatus : Hub,…
ShaneKm
  • 20,823
  • 43
  • 167
  • 296
57
votes
11 answers

SignalR cannot read property client of undefined

I'm trying to add SignalR to my project (ASPNET MVC 4). But I can't make it work. In the below image you can see the error I'm receiving. I've read a lot of stackoverflow posts but none of them is resolving my issue. This is what I did so far: 1)…
polonskyg
  • 4,269
  • 9
  • 41
  • 93
53
votes
1 answer

When does a reconnect in signalR occur?

I've started working with SignalR and was trying to figure out when a Hub Reconnect occurs. I didn't find any satisfying explanation on the web. Can someone explain when/why a reconnect occurs?
gsharp
  • 27,557
  • 22
  • 88
  • 134
52
votes
6 answers

How to get SignalR Hub Context in a ASP.NET Core?

I'm trying to get the context for a hub using the following: var hubContext = GlobalHost.ConnectionManager.GetHubContext(); The problem is that GlobalHost is not defined. I see it is part of the SignalR.Core dll. At the moment, I have the…
user2095880
52
votes
6 answers

Context.User.Identity.Name is null with SignalR 2.X.X. How to fix it?

This is driving me insane. I'm using latest signalR release (2.0.2). This is my hub code (OnConnected) public override Task OnConnected() { //User is null then Identity and Name too. …
MRFerocius
  • 5,509
  • 7
  • 39
  • 47
52
votes
2 answers

Call a hub method from a controller's action

How can I call a hub method from a controller's action? What is the correct way of doing this? Someone used this in a post: DefaultHubManager hd = new DefaultHubManager(GlobalHost.DependencyResolver); var hub = hd.ResolveHub("AdminHub") as…
sports
  • 7,851
  • 14
  • 72
  • 129
40
votes
6 answers

Passing token through http Headers SignalR

I can see that there is an option in HubConnection to pass parameters through url request from client. Is there any way to pass specific token through http headers from JS or .NET clients?
Eduard Truuvaart
  • 429
  • 1
  • 4
  • 8
37
votes
1 answer

Proper Hub dependency lifetime management for SignalR and Castle Windsor

I have some SignalR hubs which may need to access some transient and singleton dependencies. Hooking the creation of the Hub is easy and works just fine however SignalR does its own Dispose() call on the created Hub rather than notifying the…
Ian Yates
  • 1,324
  • 13
  • 24
34
votes
3 answers

Is it possible to call a SignalR Hub from Postman

I have an ASP .Net Core 2.2 Web API with a SignalR hub. Is it possible to call one of its methods (for example, SendMessageToAll) using Postman? The problem is that I only have the API - no frontend - and I need to test. I tried putting the URl to…
33
votes
1 answer

signalR - getting username

I am using signalr and asp.net MVC3 to build a sample chat application. Here is what my signalr hub looks like public class MyHub:Hub,IDisconnect { public Task Join() { string username = HttpContext.Current.User.Identity.Name; //find group…
user1625066
1
2 3
99 100