Search code examples
asp.net-core-webapigrpc

Are there rules for gRPC port number?


I am currently developing an application which will expose both REST an gRPC endpoints.

I need to set a port for the gRPC server.

Are there any rules for the port number? Any special ranges other than the standard for REST services?


Solution

  • No there are not any rules for the port number. Just be careful to assign Http2 protocol and SSL for gRPC (not mandatory but highly recommended). All you need is just to configure the Kestrel endpoints parameters in your appsettings.json. Set Endpoints with WebApi and gRPC with your custom name as follow:

      "Kestrel": {
        "Endpoints": {
          "Grpc": {
            "Protocols": "Http2",
            "Url": "https://localhost:5104"
          },
          "webApi": {
            "Protocols": "Http1",
            "Url": "https://localhost:5105"
          }
        }
      }