signalr-hub

SignalR version compatability (StatusCode: 405 'Method Not Allowed')

时光毁灭记忆、已成空白 提交于 2019-11-27 04:51:26
问题 I'm having issues with a SignalR project I'm currently working on. I'm trying to build a server using .Net Core, and a client using traditional .Net (framework 4.6.1). However the server and client don't seem to be compatible. The last issue I've run into is a StatusCode: 405, ReasonPhrase: 'Method Not Allowed'. I found an answer on GitHub that states that there are many breaking changes between versions. Looking at the NuGet package versions available, I get even more confused. for the .Net

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

浪子不回头ぞ 提交于 2019-11-27 04:21:34
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. Connections.Add(Context.User.Identity.Name, Context.ConnectionId); return base.OnConnected(); } And this is my Controller's login method: [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await UnitOfWork.UserRepository.FindAsync(model.UserName, model.Password); if (user != null) { await

Signalr/Hub not loading in IIS 7 but working correctly in Visual Studio

北城以北 提交于 2019-11-27 04:03:39
问题 I am working on a Web Application on the Asp .Net 4.0 framework that uses SignalR, having installed it from the Nuget package. When I debug or run the application without debugging locally it works correctly. However, when it is deployed to the production server it is unable to find the signal/hubs file that is being dynamically injected into the httphandlers. Due to it's dynamic nature it has to be created on the fly, so I can't just copy the working file into the project either. I have

Get number of listeners, clients connected to SignalR hub

守給你的承諾、 提交于 2019-11-27 00:55:50
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, IDisconnect { static CancellationTokenSource tokenSource; public void GetTasksStatus(int? siteId) { tokenSource = new CancellationTokenSource(); CancellationToken ct = tokenSource.Token; ITaskRepository taskRepository = UnityContainerSetup.Container.Resolve<ITaskRepository>(); // init task for checking task statuses var tasksItem = new DownloadTaskItem();

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

做~自己de王妃 提交于 2019-11-27 00:35:12
问题 I'm trying to get the context for a hub using the following: var hubContext = GlobalHost.ConnectionManager.GetHubContext<SomeHub>(); The problem is that GlobalHost is not defined. I see it is part of the SignalR.Core dll. At the moment, I have the following in my project .json file, under dependencies: "Microsoft.AspNet.SignalR.Server": "3.0.0-*" If I add the latest available version of Core: "Microsoft.AspNet.SignalR.Server": "3.0.0-*", "Microsoft.AspNet.SignalR.Core" : "2.1.2" I get a whole

Passing token through http Headers SignalR

对着背影说爱祢 提交于 2019-11-26 19:23:54
问题 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? 回答1: There is no easy way to set HTTP headers for SignalR requests using the JS or .NET client, but you can add parameters to the query string that will be sent as part of each SignalR request: JS Client $.connection.hub.qs = { "token" : tokenValue }; $.connection.hub.start().done(function() { /* ... */ });

SignalR calling client method from outside hub using GlobalHost.ConnectionManager.GetHubContext doesn't work. But calling from within the hub does

萝らか妹 提交于 2019-11-26 19:14:54
问题 I'm trying to call a client method from within a .net Web API controller action. Can I do this? The only post I can find that comes close to what I am looking to do is this one: SignalR + posting a message to a Hub via an action method In there a message is sent from within an asp.net MVC controller action using GlobalHost.ConnectionManager.GetHubContext. When I try that inside my Web API action no errors are thrown, but the method "methodInJavascript" is never invoked on the client side.

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

陌路散爱 提交于 2019-11-26 18:46:25
问题 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 to: http://localhost:50682/6a663a78019845d5ade4a328cad09cc2/arterySignalR/poll?transport=longPolling&connectionToken=AQAAANCMnd8BFdERjHoAwE%2FCl%2BsBAAAAOBmDwPWa2ky2MAZXFHBMVAAAAAACAAAAAAAQZgAAAAEAACAAAADSADQXBVKiKczflJ0OzUjOLduFTJE4zd%2FLHWGpDfXnuAAAAAAOgAAAAAIAACAAAACyEX81VwilygfphPoEKCYQ6ZwrkzExoKfZzEMkqBKqqzAAAADG

How to use SignalR hub instance outside of the hubpipleline

百般思念 提交于 2019-11-26 15:36:22
问题 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 as: Using a Hub instance not created by the HubPipeline is unsupported. 回答1: You need to use GetHubContext : var context = GlobalHost.ConnectionManager.GetHubContext<chatHub>(); context.Clients.All.Send("Admin", "stop the chat"); This is described in

SignalR doesn&#39;t use Session on server

随声附和 提交于 2019-11-26 14:21:49
问题 When I try to access the HttpContext current session from the HUB it returns null . I tried making use of the interface IRequiresSession but it didn't work. Can someone help me? 回答1: SignalR connections (including the connection underlying all Hub operations for a client) do not support Session state. You could enable it if you wanted to but we'd strongly recommend against it as session state access serializes requests for a given client, meaning you won't really get the benefit from SignalR