Reputation: 556
I'm trying to host an asp.net core 2.0 web API in an IBackgroundTask. The background task is deployed on an raspberry pi 3 running Windows 10 iot core build 16299.
My setup has two projects:
For the background application I've checked the capabilities:
I'm running the Kestrel server with the following code:
public void Run(IBackgroundTaskInstance taskInstance)
{
var deferral = taskInstance.GetDeferral();
using (var host = WebHost.CreateDefaultBuilder()
.UseStartup<Startup>()
.UseUrls("http://*:5001")
.Build())
host.Run();
deferral.Complete();
}
And opened the ports using the following PowerShell command:
netsh advfirewall firewall add rule name="FezHat.Web.Api" dir=in action=allow protocol=TCP localport=5001
But the following exception is thrown:
System.IO.IOException: 'Failed to bind to address http://[::]:5001: address already in use.'
I've tried different port numbers, but the exception keeps throwing. When I host the API from an .net core console application on my PC the API works.
How can I host the API from an iot background application on an raspberry pi 3?
Upvotes: 2
Views: 700
Reputation: 13
This could be an errant instance continuing to run from a previous debug session that isn't disposed properly. I would check out Microsoft Message Analyzer though. It's been very helpful to me.
Upvotes: 0