I've created a Windows Service (using Topshelf package) that uses WebApp.Start to listen to http requests. My code is as follows:
var options = new StartOptions();
options.Urls.Add( "http://localhost:9095" );
options.Urls.Add( "http://127.0.0.1:9095" );
options.Urls.Add( $"http://{ConfigurationHelper.IPAddress}:9095" );
options.Urls.Add( $"http://{Environment.MachineName}:9095" );
Microsoft.Owin.Hosting.WebApp.Start<Startup>( options );
I can hit all the desired URLs when I'm browsing on the Windows Service machine, but when I'm on a remote machine on the same network with access to the machine, I get a 500 error when hitting the URL (i.e. http://192.168.100.14:9095/hangfire/).
Some notes:
Windows Firewall is turned off, but I'm still confirming with IT whether or not our hardware firewall might be blocking something (would we get 500 if that was case or 404?)
The windows service is running as a local user that is part of the Administrators group.
For each of those URLs, I ran the
netsh
command:netsh http add urlacl url=http://127.0.0.1:9095/ user=myAdminUser
Any other ideas on why I'd get a 500 or how to see any diagnostic information anywhere? (debug view and event viewer have nothing).
It is my first Owin application, so I'm very green on it yet.
Update: OWIN error trace
[8496] BTR.Evolution.Service OWIN Exception: Object reference not set to an instance of an object.
[8496]
[8496] at Hangfire.Dashboard.MiddlewareExtensions.Unauthorized(IOwinContext owinContext)
[8496] at Hangfire.Dashboard.MiddlewareExtensions.<>c__DisplayClass1_2.b__1(IDictionary`2 env)
[8496] at Microsoft.Owin.Mapping.MapMiddleware.d__0.MoveNext()
[8496] --- End of stack trace from previous location where exception was thrown ---
[8496] at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[8496] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[8496] at BTR.Evolution.Service.GlobalExceptionMiddleware.d__1.MoveNext() in C:\BTR\Source\Evolution.Service\BTR.Evolution.Service\Startup.cs:line 20
So maybe it wasn't OWIN that was the culprit but rather Hangfire and my attempt to use it remotely. Going to look into authorization filter to see if that will help.