✅ How to deploy gRPC Server + Client via docker
I wish to have a gRPC server and multiple clients connected to said server. In my current setup, I have two Blazor-server clients and a bare-bones console app client.
Only the console app is currently configured as a receiving client.
The goals are:
1. Communicate with the server from my local env. to the running docker instance.
2. Enable the aforementioned applications to communicate with each other.
Unfortunately, I'm having issues with both goals. At some point, I was able to send requests to the server (goal 1); however, the apps still refused to connect (goal 2).
I've started from scratch and uploaded the project online for you to have a closer look: https://github.com/hailstorm75/GrpcDocker-Experiment
For goal 1 I have tried various combinations of exposing ports in the docker-compose, Dockerfile, even dabbled in configuring servers
appsettings.json
and launchSettings.json
. However, all of my attempts are just throwing things at the wall and seeing what sticks, without really understanding where I need to configure the ports.
Running locally, I'm able to access the server and send a request.
Running via docker, I see the exposed ports, however, I'm unable to send a request.
Opening the port links shown in the image gives me an empty response in the browser, instead of the mapped "Communication with gRPC endpoints must be made through..." message.
I'm testing the communication with the server via Postman. I've tried various ports, combined with enabled and disabled TLS just to be sure.
With goal 2 I'm simply getting a SocketException
:
16 Replies
I'm getting this exception in the
ConsoleListener
when attempting to iterate the ResponseStream
:
When attempting the run the docker-compose via Rider, I get an InvalidOperationException
:
Maybe this is a certificate issue? Why is it behaving differently in VS?Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Thank you for the elaborate answer @TeBeCo, let me read through and wrap my head around it
I suppose one of them was supposed to be a client, and not two servers
Wow this is insanely compliment. But I suppose I have no other choice
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
The goal for this application in its current state is to:
- use docker deployment for testing purposes
- be capable of deploying to the cloud
- be able to deploy to a on-premises environemnt
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yeah, that makes sense
But a real domain isn't something I can get, afaik
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I mean that this project will be deployed to multiple customers - should I be the one providing the certificate?
those customers will prefer on-premises for now, so I cannot use a complete cloud solution for the start
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
https://learn.microsoft.com/en-us/aspnet/core/security/docker-https?view=aspnetcore-7.0
I suppose I should follow this.
Thank you, for explaining everything in detail!
Hosting ASP.NET Core Images with Docker over HTTPS
Learn how to host ASP.NET Core Images with Docker over HTTPS
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.May just be the same question, on which I get a different error, seen on this image.
So, I have a microservice where I can also retrieve data via gRPC, but the thing only works locally with developer certificates. When I call the gRPC endpoint running from a Docker container, I get the following exception: [link to exception].
At this point, I honestly don't understand exactly what I need to do, or rather, I know I need to:
Generate a certbot certificate for the specific microservice.
Include this certificate in the Docker image so that I can somehow get around Github CI (okay, I could just push the dev Docker image, but that's not correct).
Ensure that it runs on the Kubernetes cluster.
I'm already having trouble just generating the certificate on the Docker container. All the guides require me to run docker-compose and do something else, which in my case (as far as I understand) is not applicable. It's clear to me that I don't understand certain things, but I'm interested in where (aside from official documentation) I can learn more. I would just like to run my microservices inside of the docker containers on a kubernetes cluster.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Yeah, thought so. Okay, i'll Just open a new thread.