question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@grpc/grpc-js not working with aws ALB

See original GitHub issue

Problem description

I was trying to use grpc with ALB, considering this documentation from AWS: https://aws.amazon.com/pt/blogs/aws/new-application-load-balancer-support-for-end-to-end-http-2-and-grpc/

I created the Load balancer, target group, cluster, service and task definition using an ECR image with this hello-world server example from grpc repo. I tried dynamic and static proto generation and both returned this error:

Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
(node:1500234) UnhandledPromiseRejectionWarning: Error: 13 INTERNAL: Received RST_STREAM with code 2 triggered by internal client error: Protocol error
    at Object.callErrorFromStatus (/home/gustavosartori/validate-grpc-alb/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/home/gustavosartori/validate-grpc-alb/node_modules/@grpc/grpc-js/build/src/client.js:180:52)
    at Object.onReceiveStatus (/home/gustavosartori/validate-grpc-alb/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:336:141)
    at Object.onReceiveStatus (/home/gustavosartori/validate-grpc-alb/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
    at /home/gustavosartori/validate-grpc-alb/node_modules/@grpc/grpc-js/build/src/call-stream.js:160:78
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

After that to make sure the error wasn’t in my hello-world server I changed the ECR image to another grpc-server(using @grpc/grpc-jt) that I already have working on aws, and the error persists.

To finish I decided to test using the python hello world example, and it worked, so I believe the @grpc/grpc-js have some bad interaction with ALB, but I don’t know exactly how debug this

Reproduction steps

  • Upload to ECR any grpc server (I used this hello-world example)
  • Create a Cluster making sure to use an security group that allow traffic to the port used in the Dockerfile;
  • Create a Target group: type = instance; protocol = http; port = 50051; protocol version = grpc;
  • Create an Application Load Balancer configured to listen on 50051 and route to the just created target group;
  • Create a task definition using the image uploaded to ECR
  • Create a service to this task definition, in the load balancing section select the load balancer and target group created for the test
  • Start de client using the dns of the ALB as url

Environment

Additional context

I tried generate a cert with openssl in order to no use grcp.createInsecure, but it changed nothin

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
cabulafhycommented, May 4, 2022

I’ve been looking into this with @g-sartori and we found the problem.

ALB ensures that only HTTPS listeners can foward requests to a gRPC target group, but we were consuming the server like it did’nt had any TLS/SSL in front of it. So we changed the way we created the client and it worked.

We were creating the client like this

var client = new hello_proto.Greeter(target, grpc.credentials.createInsecure())

And we changed to this

var client = new hello_proto.Greeter(target, grpc.credentials.createSsl())

In this documentation https://aws.amazon.com/pt/blogs/aws/new-application-load-balancer-support-for-end-to-end-http-2-and-grpc/ they do the same thing for the python hello-word example using credentials = grpc.ssl_channel_credentials()

1reaction
murgatroid99commented, Apr 20, 2022

That capture shows that the server is responding with the error HTTP/1.1 400 Bad Request. Something is misconfigured and the front end your client is talking to isn’t handling HTTP/2. And the client doesn’t understand an HTTP/1.1 response to an HTTP/2 request, so that’s why the error is “Protocol error”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

New – Application Load Balancer Support for End-to-End ...
Since I am planning to use AWS Fargate to run the gRPC server, I select the IP address target type. The ALB supports...
Read more >
GRPC API through AWS ALB
Hi, I'm trying to run a netty server with GRPC API on ECS (on Fargate) behind an application load balancer for an Android...
Read more >
Developers - @grpc/grpc-js not working with aws ALB -
grpc /grpc-js not working with aws ALB. ... Problem description. I was trying to use grpc with ALB, considering this documentation from AWS: ......
Read more >
Any success with GRPC and the new AWS Application Load ...
1) With plaintext GRPC on the backend, ALB fails because it tries to upgrade from HTTP/1.1 which grpc-java does not support. 2) With...
Read more >
NodeJS gRPC client is getting UNAVAILABLE without retrying
With regard to your environment, one common problem that people see when using gRPC with AWS is that DNS doesn't provide a way...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found