locked
Could not connect RRS feed

  • Question

  • User827910976 posted

    Hallo there,

    I have a windowsservice (TopShelf) with owin selfhost web api.

    i start the http listener in this way:

    ------------------------------------------------------------------------------------

    var options = new StartOptions();
    options.Urls.Add($"http://localhost:{_config.ApiPort}");
    options.Urls.Add($"http://127.0.0.1:{_config.ApiPort}");
    options.Urls.Add($"http://{Environment.MachineName}:{_config.ApiPort}");
    options.Urls.Add($"http://+:{_config.ApiPort}");
     _server = WebApp.Start<WebApiConfig>(options);

    ------------------------------------------------------------------------------------

    when i start the Project in VS2017 all works fine.

    when i start the Service on my remote mashine (Win7 x64) it seems al fine,

    but i can't connect to the api. ERR_CONNECTION_REFUSED

    Firewall is off

    any idea ?

     

    Tuesday, November 14, 2017 12:59 PM

All replies

  • User475983607 posted

    There is not enough information in the code snippet to guess at a solution.  Consider posting all the relevant code and describing the design intention. 

    Is this an ASP Core app?  Web API 2 and Owin?  Are you trying to make a remote connection to the API or is the API and caller on the same system?  Can you post the startup code and client code?

    Tuesday, November 14, 2017 2:30 PM
  • User1168443798 posted

    Hi kermitfrosch,

    To check whether the web api is running, I suggest you try to access web api from the hosted machine, will it work?

    What is the user the windows service running under?

    For this issue, it is usually caused by the firewall and the web api could not open the port due to permission issue.

    I suggest you run below command to grant permission for the specific user.

    netsh http add urlacl url=http://*:port/ user=<your user>

    Best Regards,

    Edward

    Wednesday, November 15, 2017 5:09 AM