I followed the step-by-step instructions from http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api .
Here is the console application code:
namespace OWINTest
{
class Program
{
static void Main(string[] args)
{
string baseAddress = "http://localhost:1961/";
WebApp.Start<Startup>(url: baseAddress);
...
}
}
class Startup
{
public void Configuration(IAppBuilder appBuilder)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
appBuilder.UseWebApi(config);
}
}
public class ValuesController : ApiController
{
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
}
The following is true:
- OWIN server is running (can connect from one computer using Fiddler, browser)
- An instance of the EC2 instance opens in incoming traffic through the security group.
- No other processes are listening on this port.
- OWIN Version - Microsoft.AspNet.WebApi.OwinSelfHost 5.2.2
- .NET 4.5 installed on an EC2 instance
The problem I am facing:
HTTP/1.1 502 - Connection Failed error when calling http://(uc2-00-000-000-us-west-1.compute.amazonaws.com):1961/api/values with the following message: The connection to 'ec2-00-000-000-us-west-1.compute.amazonaws.com' failed. Error: TimedOut (0x274c). System.Net.Sockets.SocketException A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I tried the following without success:
1. 'netsh http add urlacl url=http://localhost:1961 user=everyone'
2. 'netsh http add urlacl url=http://+:1961 user=everyone'
3. 'netsh http add urlacl url=http://*:1961 user=everyone'
source
share