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

Status codes and error messages are displayed incorrectly on the angular client. #1126

Open
Quttar opened this issue Oct 6, 2022 · 4 comments

Comments

@Quttar
Copy link

Quttar commented Oct 6, 2022

I am using the following code to get the result of executing a unary grpc request from a client.

client.login(req, (error, response) => {
      if (response != null) {
        this.tokenService.saveToken(response.getAccesstoken());
      }
      else{
        alert("Error code: " + error?.code + "Message: " + error?.message);
      }
    });

When the server just returns the result, then everything works as it should. But if the server should return an error, then no matter what status code and message the server returns, this code always outputs the following line:

Error code: 2 Message: Response closed without grpc status (headers only)

At the same time, I'm testing the API using the Kreya tool (In normal gprc mode and in grpc-web mode). In this program, all status codes and error messages are displayed correctly.

On the backend I use ASP.NET Core with Grpc.AspNetCore.Web nuget package to support grpc-web

What could be the matter that the error status code and the message are always the same?

@johanbrandhorst
Copy link
Contributor

Seems like the library doesn't like the way that errors are sent from the backend. Could you include a copy of the body of the response when you get this error? In grpc-web the status should be included at the end of the body. Maybe it's encoded in an unexpected way?

@DaAitch
Copy link

DaAitch commented Dec 18, 2022

I had the same problem and the reason was CORS. Without access-control-expose-headers header the client is not allowed to read the grpc headers and returns the message you mentioned.

Solution
server should set

  • access-control-expose-headers: * or at least
  • access-control-expose-headers: grpc-status,grpc-message

@KAW0
Copy link

KAW0 commented Jun 23, 2023

@DaAitch saddly it doesn't work for me

@dmitryshelomanov
Copy link

same issue #1177

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

5 participants