SignalR in ASP.Net Core self host

Viewed 1827

Is it still possible to self-host a SignalR Hub (server) without using IIS / Kestrel?

MS does not have any information as though if it is still possible (using asp.net core migration) to achieve this.

My use case for this would be to be able to deploy both the client and the server to local machines and then be able to easily switch to remote servers at a later stage. Ideally, the client would host the server for now.

2 Answers

ASP.NET Core implies using Kestrel as its web server. That means that in order to host a SignalR hub (server), you will need to use Kestrel and basically build an ASP.NET Core application.

You will however not need to use IIS or some other web server to host the application. Kestrel on its own already is a full web server, so you can use it directly without needing anything else.

The ASP.NET Core application hosting your SignalR hub also doesn’t need to do any other web-stuff. It would be totally fine for it to just contain the single hub and host just that. So you usually don’t need to worry about it too much.

So, to address your use case: Yes, you could have a separate ASP.NET Core application hosting the hub and start that directly on the client and the client could connect to it. And then later you could have another ASP.NET Core application hosting the hub running elsewhere and reconfigure the client to use that one then.

Yes, you can self host .NET Core SignalR.

A SignalR server is usually hosted in an ASP.NET application in IIS, but it can also be self-hosted (such as in a console application or Windows service) using the self-host library.

You can read more about it here.

Related