Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR HubConnection Invalid URI

Tags:

c#

owin

signalr

Based on an example I found, http://weblog.west-wind.com/posts/2013/Sep/04/SelfHosting-SignalR-in-a-Windows-Service, I'm implementing a SignalR host server within a Windows Service.

It all works fine but if I try:

SignalR = WebApp.Start<SignalRStartup>("http://*:8080/");

I get an unhandled exception of type `

'System.UriFormatException'` occurred in System.dll

Additional information: Invalid URI: The hostname could not be parsed.

It works fine if I use

SignalR = WebApp.Start<SignalRStartup>("http://localhost:8080/");

Probably a dumb assumption but based on the article I took this from, I assumed the *:8080 syntax would work. My question is, have I missed something or was the article incorrect and this format won't work?

like image 940
user3043799 Avatar asked Nov 12 '22 17:11

user3043799


1 Answers

So, the + does work... (and yes, I feel dumb) During my testing I think only 1/2 the time I remembered to run as administrator, which lead to bad test results since it was failing because of trying to open the port, and not because of the address.

I got clued into this by reading the Owin/Katana source code linked by @DigitalD. Turns out that not only does it support the + syntax, there is a comment from the code saying it's assuming it...

http://katanaproject.codeplex.com/SourceControl/latest#src/Microsoft.Owin.Host.HttpListener/OwinHttpListener.cs

// Assume http(s)://+:9090/BasePath/, including the first path slash. May be empty. Must end with a slash.
like image 154
Peter Avatar answered Nov 27 '22 05:11

Peter