0
votes

Issue:
When running the Web API, self hosted using OWIN, All HTTP connections are refused (no status code returned), but only on a particular test machine, not on any other machines (they all work fine).

Sample code:

public static void Main(string[] args){
    var options = new StartOptions();
    options.Urls.Add($"http://+:{port}");
    using(Microsoft.Owin.Hosting.WebApp.Start<Startup>(options)){
        Console.WriteLine("Press Enter to exit.");
        Console.ReadKey();
    }
}

Additional info:
- Running as admin eliminates urlacl as being the cause of the problem. so url port reservations are not the issue.
- Tried using various port numbers to eliminate port number conflicts.
- Making the service use + url prefix in it's baseurl eliminates other listeners intercepting the request.
- Calling localhost (and other hostnames that resolve to 127.0.0.1) eliminates firewall.
- Code has been run with debugger, no exceptions there.
- There is no entry when i run netstat for that port. (The working machines show an enrty.)

Question:
I'd like to know what the issue is with this particular machine, and how to resolve it. What do you suggest in order to achieve this?

Related Questions that did not answer my question (or were not applicable):
Self-hosted OWIN project; http://localhost:8080 won't work, http://+:8080 does?
HTTP 503 Service is unavailable when trying to browse signalr/hubs
Self hosted OWIN and urlacl
Owin selfhost: using netsh to add an urlAcl seems to cause 503

1

1 Answers

0
votes

She solution turns out to be something seemingly unrelated.
In the Startup class, it was trying to enter A duplicate database entry and throw an exception. However this exception was wrapped within a TargetInvocationException that was already being handled (and incorrectly consumed).
The error handling was updated and all systems are now listening on the specified port correctly.