I have a .NET Web API where I have installed dotnet add package Dapr.AspNetCore
and have included this in the service collection:
services.AddControllers().AddDapr();
app.UseEndpoints(e =>
{
e.MapSubscribeHandler();
e.MapControllers();
});
I have this POST
method:
// Route is /login
[Route(Program.ROOT + Program.TOKEN)]
[HttpPost]
[Consumes("application/json")]
public async Task<IActionResult> Login([FromBody][Required] JsonDocument jsonData)
{
IResult result = await Task.Run(() => _userCommander.LoginUser(jsonData));
return result.Ok ? Ok(result.Value) : BadRequest(result.Value);
}
I runned dapr init and have the config filed in $HOME/.dapr
.
I currently only run the dapr locally with this terminal command inside the API folder where program.cs
is located. I have tried both with and without the app-protocol:
dapr run --app-id webapi --app-port 51669 --dapr-http-port 3500 --app-protocol=https -- dotnet run
When I then use dapr list I can verify that the WebAPI service is running:
APP ID HTTP PORT GRPC PORT APP PORT COMMAND AGE CREATED DAPRD PID CLI PID APP PID
webapi 3500 53942 51669 dotnet run 3m 2023-11-13 13:56.24 8192 8184 8193
When I try to send a post request to my endpoint it cannot find the service to invoke. I send the Json body I need to send with the url below through Postman:
http://localhost:3500/v1.0/invoke/webapi/method/login
Which results in this error message here:
{
"errorCode": "ERR_DIRECT_INVOKE",
"message": "failed to invoke, id: webapi, err: couldn't find service: webapi"
}
I do not understand why it cannot find the WebAPI service when I use dapr list and can see the service there. In the image below there is logs for when I run the dapr on my project.
There are certain anti-virus/security software that may block mdns requests (which is what dapr uses for service discovery when running locally).
For me, disabling the McAfee solved this.
It worked well with my VPN. but this also could help to try diable and check again while the VPN is off.