I have an app where I need to use both Asp.Net WebApi, and SignalR in a self-hosted manner. Currently, this means that I have to run two separate self-host processes on different ports.
I should be able to use the AspNet WebApi self-host and have SignalR bolted on, but WebApi uses HttpRoutes, while SignalR expects a regular Route. So you can't use the routes.MapConnection() on the WebApi configuration's routing table.
WebApi's self host is superior anyway, because it has support for message handlers. The best that SignalR's self host has is Server.OnProcessRequest, and you can't cancel a request there without it throwing an exception and crashing the server.
In my opinion, There should be extension methods in the SignalR.Hosting.AspNet package that allow it to work with the WebApi self-host server - or there should be a SignalR.Hosting.WebApi package.
We're working on webapi integration that will make this smoother. Also, it seems you're confused as to what self hosting SignalR means. We're not providing a full http stack, it's purely for SignalR interaction. So I agree, WebApi is superior because it's a full http stack 😄.
This will be supported via OWIN in a future release.
Noticed that you have the stuff posted for OWIN. any cookie crumbs you and @davidfowl can add to the docs on how we get SignalR and ASP.Net Web API to exist nicely in a self hosted scenario @DamianEdwards ???
We plan to have a specific nuget package for the RC2 release that pulls in all the pieces required for self-hosting SignalR using OWIN and HttpListener. That should clear things up quite a bit.
Just wondering if you could update us on the status of this issue now that RC2 has been released? Are there any docs on how to achieve this or is it still a backlog item?
what is the status of this issue, i am hosting singalR and webapi on windows service and singalr does not work....
@bsurela - it's been a few months since I've looked at this, but as far as I recall what you're trying to do should now work. You might need the SignalR OWIN packages to do it..
@bsurela You need to use the WebApi owin host which is currently is preview state.
Just came across this when searching on google. Anyone who got an example of doing this with owin with 2.0 release candidate of signalr and webapi.
@s093294 we have a pre-release doc on using OWIN self-host with 2.0 http://www.asp.net/signalr/overview/getting-started/tutorial-signalr-self-host
Thanks. I got it working. My Startup class can be found at https://gist.github.com/s093294/6457561 if someone else want to run webapi/signalr together (and using the Owin.Cors also).