Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why .NET 7 Sample API get "error invoking app service-a: 500 Internal Server Error" use dapr #822

Open
LuBu0505 opened this issue Apr 2, 2023 · 5 comments
Assignees
Milestone

Comments

@LuBu0505
Copy link

LuBu0505 commented Apr 2, 2023

Ask your question here

I Have create a very sample .net 7 API and use dapr run it in my local environment.

My API Code:

var builder = WebApplication.CreateBuilder(args);


var app = builder.Build();

app.MapGet("/Hello", () => "Hello World!");

app.MapGet("/GetServiceA", () =>
{
    //return new Data() { ID = 1, Name = "Service A", };
    return "This result from Service A";
});


app.Run();

and start this app by dapr run.
dapr run --app-id service-a --app-port 5001 dotnet run

After that, I saw this app already run.

PS C:\LBWorkSpace\MyCode\68-Dapr-Dotnet7\githubstartdemo\hello-world\node> dapr list
APP ID HTTP PORT GRPC PORT APP PORT COMMAND AGE CREATED DAPRD PID CLI PID APP PID RUN TEMPLATE PATH
nodeapp 3500 64657 3000 node app.js 21m 2023-04-02 12:16.29 23400 20488 18696
pythonapp 53800 53801 0 cmd /c python app.py 7m 2023-04-02 12:30.25 18648 17100 25128
service-a 56727 56728 5001 dotnet run 30s 2023-04-02 12:37.05 14996 8124 17064

But Why I can not invoke this method.

dapr invoke --app-id service-a --method Hello
dapr invoke --app-id service-a --method getservicea

Always get 500 error.

Cloud you please tell me why?

PS: I also used the quick starts dome -- "https://github.com/dapr/quickstarts/tree/v1.5.0/hello-world", It works. But for my Net 7 API. Not.

@LuBu0505
Copy link
Author

LuBu0505 commented Apr 2, 2023

attached the error screenshot.
https://github.com/LuBu0505/My-Code/blob/main/githubdapr.png?raw=true

@msfussell
Copy link
Member

Maybe you just need to do this, with the GET verb
dapr invoke --app-id service-a --method Hello --verb GET
dapr invoke --app-id service-a --method GetServiceA --verb GET

Otherwise.
Have you checked the ports you are using?
Is some other app using port 5001?

@paulyuk paulyuk added this to the 1.11 milestone Jun 2, 2023
@paulyuk
Copy link
Contributor

paulyuk commented Jun 2, 2023

@LuBu0505 thanks for report.

As @msfussell says this exact command works for me with your code adding --verb GET
dapr invoke --app-id order-processor --method Hello --verb GET

However, I believe you're missing an --app-protocol http flag on dapr run that tells the app to run on HTTP instead of gRPC -- could you please try this?
dapr run --app-id service-a --app-port 5001 --app-protocol http -- dotnet run

May I suggest you first try the Service Invocation Quickstart in entirety? That shows how to set the app-protocol and test. Then, I suggest copy in your MapGet functions, and try the dapr invoke with the --verb GET. That should resolve.

@msfussell
Copy link
Member

@LuBu0505 - Any other update here? Did you try out the suggestions above ^ ^ ?

@vamanpnayak
Copy link

vamanpnayak commented Oct 27, 2023

I am also facing similar issue. when try to do service invocation working.

I have two services one Client and one Server named. Attempted service invocation from Client app to Server app. used both DaprClientBuilder client and DaprClient.CreateInvokeHttpClient. Both cases I see internal server error when Client app attempting to POST request to Server app.

Dapr version : 1.12

Attempted to give a try via postman directly to dapr sidecar port. http://localhost:{{dpartPortServerApp}}/v1.0/invoke/order-processor/method/Order/Create and it is actually giving same internal server 500 error.

I could see the instances running in Dapr dashboard. Not sure how to get more insight on what's wrong.

Client : dapr run --app-id checkout --app-port 7200 --app-protocol http --dapr-http-port 3500 -- dotnet run
Server : dapr run --app-id order-processor --app-port 7201 --app-protocol http --dapr-http-port 3501 -- dotnet run

If I attempt directly to the Server controller route from Postman (as normal API). It works : http://localhost:7201/Order/Create but not via service invocation mechanism.

Also, I have also used Quickstart as it from the dapr docs. Only checkout app invokes but order-processing doesn't receive.
Checkout is getting internal server error when trying to invoke order-processing. (of course, that logic is not handled in quickstart app code. So it logs as order passed)

image

image

Any hints? if needed i can share the testapp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants