Setup gRPC DB-less API gateway: 415 Unsupported Media Type

I am current setup kong for my project. originally, server is monolith architecture), my team want to separate it into microservice. As my project using gRPC to communicate between client and server, I am thinking of using an API gateway support gRPC. I find Kong in Google and Medium suggested. and I have set it up with DB-less mode. I use docker-compose to run. Below is what I did:

Here is docker-compose.yml

version: '3'
networks:
    kong-net:
        driver: bridge
services:
    gateway:
        image: kong:2.0.2
        networks:
            - kong-net
        volumes:
            - ./../kong:/var/lib/docker/volumes/kong-vol/_data
        environment:
            KONG_SSL:                       "off"
            KONG_DATABASE:                  "off"
            KONG_DECLARATIVE_CONFIG:        /var/lib/docker/volumes/kong-vol/_data/kong.yml
            #KONG_SSL_CERT:                  /
            #KONG_SSL_CERT_KEY:              /
            KONG_PROXY_LISTEN:              0.0.0.0:8000, 0.0.0.0:8443 ssl, 0.0.0.0:9080 http2, 0.0.0.0:9081 http2 ssl
            KONG_ADMIN_LISTEN:              127.0.0.1:8001, 127.0.0.1:8444 ssl
        ports:
            - "8000:8000"
            - "8443:8443"
            - "8001:8001"
            - "8444:8444"
            - "9080:9080"
            - "9081:9081"
        healthcheck:
            test: ["CMD", "kong", "health"]
            interval: 5s
            timeout: 2s
            retries: 15
        restart: on-failure
    appserver:
        image: saigonparkingmap/appserver:v1.0
        networks:
            - kong-net
        ports:
            - "9090:9090"
            - "9999:9999"
        depends_on:
            - gateway

Here is kong.yml

services:
    -   name: appserver
        url: http://localhost:8001/services
        protocol: grpc
        host: appserser
        port: 9999
        connect_timeout: 30000
        write_timeout: 30000
        read_timeout: 30000
        routes:
            -   name: parking-lot-service
                protocols:
                    - grpc
                paths:
                    - /com.bht.parkingmap.api.proto.parkinglot.ParkingLotService/

And I faced 415 Unsupported Media Type Error response from Kong.

Here is what I received from client console:

Caused by: io.grpc.StatusRuntimeException: UNKNOWN: HTTP status code 415
invalid content-type: text/html; charset=UTF-8
headers: Metadata(:status=415,content-type=text/html; charset=UTF-8,content-length=144,date=Sun, 29 Mar 2020 23:24:57 GMT,access-control-allow-origin=*,server=kong/2.0.2,x-kong-admin-latency=381,x-kong-upstream-latency=381,x-kong-proxy-latency=2,via=kong/2.0.2)
DATA-----------------------------
<html>
<head><title>415 Unsupported Media Type</title></head>
<body>
<center><h1>415 Unsupported Media Type</h1></center>
</body>
</html>

	at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:240)
	at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:221)
	at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:140)
	at com.bht.parkingmap.api.proto.parkinglot.ParkingLotServiceGrpc$ParkingLotServiceBlockingStub.getParkingLotById

And here is what I received from Kong Docker Container:

gateway_1    | 2020/03/29 23:24:56 [warn] 23#0: *490 a client request body is buffered to a temporary file /usr/local/kong/client_body_temp/0000000001, client: 172.20.0.1, server: kong, request: "POST /com.bht.parkingmap.api.proto.parkinglot.ParkingLotService/getParkingLotById HTTP/2.0", host: "localhost:9080"
gateway_1    | 127.0.0.1 - - [29/Mar/2020:23:24:57 +0000] "POST /services/com.bht.parkingmap.api.proto.parkinglot.ParkingLotService/getParkingLotById HTTP/1.1" 415 144 "-" "grpc-java-netty/1.27.2"
gateway_1    | 172.20.0.1 - - [29/Mar/2020:23:24:57 +0000] "POST /com.bht.parkingmap.api.proto.parkinglot.ParkingLotService/getParkingLotById HTTP/2.0" 415 144 "-" "grpc-java-netty/1.27.2"

I use a stub of ManagedChannel from client call to Kong gateway port 9080 and look forward it will come to service server listening on port 9999.

Client (Stub) ----> Kong :9080 ----> Service :9999

Did I miss something in the configuration or I misunderstand anything about the grpc gateway ?
I am looking forward to receive your support ! Thank you very much.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ