Skip to content

grpc response cannot be decoded #796

Closed
@yangchnet

Description

I have a grpc request:

GRPC 127.0.0.1:8090/ListenerDiscoveryService/FetchListeners

{
    "node": {
        "id": "xxx",
        "metadata": {
            "type": "proxy"
        }
    },
    "type_url": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"
}

This is a steam rpc request to envoy xds-server,its definition can be found here: https://github.com/envoyproxy/data-plane-api/blob/main/envoy/service/listener/v3/lds.proto

The response of this request:

{
  "versionInfo": "2024-09-20T19:59:36+08:00/138",
  "resources": [
    {
      "type_url": "type.googleapis.com/envoy.config.listener.v3.Listener",
      "value": {
        "type": "Buffer",
        "data": [
          10,
          7,
          115,
          117,
          45,
          116,
          101,
          ...
         ]
      }
    },
}     

When I use postman to request, it returns the following:

{
    "resources": [
        {
            "type_url": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",
            "value": "ChdvdXRib3VuZHwzMDAwfHx0ZXN0MDYyOQ=="
        }
     ]
}

I tried decoding it with a script but I got gibberish:

{{+after

    const jsonData = JSON.parse(response.body);
    // console.info(jsonData.resources[0].value.data)

    jsonData.resources.forEach(resource => {
        const decodedValue = Buffer.from(resource.value.data, 'base64').toString('utf8');
        resource.value = decodedValue;
        console.info(decodedValue);
    });
    
}}

console log:

INFO: 
�owt.pdl.test��
��
241.0.0.47��	������
-envoy.filters.network.http_connection_manager"��

How can I turn it into a readable json?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions