https://linen.dev logo
#general
Title
# general
t

TheUsharik

02/26/2024, 12:00 PM
Hello! I need some help with Wiremock gRPC plugin. After configuring it with mapping like that
Copy code
{
  "request": {
    "method": "POST",
    "urlPath": "/dbag.energy.m7g.internal.core.v1.DataAccessService/WatchOutputEvents"
  },
  "response": {
    "status": 200,
    "headers": {
      "Content-Type": "application/grpc+json"
    },
    "jsonBody": {
      "snapshot": {
        "orders": {
          "order": [
            {
              "id": "1"
            },
            {
              "id": "2"
            },
            {
              "id": "3"
            }
          ]
        },
        "product_snapshot": {
          "product": []
        }
      }
    }
  }
}
I'm getting errors at the client side like that
Copy code
Exception in thread "main" io.grpc.StatusException: INTERNAL: gRPC frame header malformed: reserved bits not zero
I've tried different client configurations with palintext parameter and without it but result is generally the same. Could you hel;p me to guess what could be wrong there...
t

Tom

02/26/2024, 12:58 PM
Bit of a punt, but have you tried removing the Content-Type header?
t

TheUsharik

02/26/2024, 1:56 PM
Yes. I'm getting error that content type null is wrong.
As an alternative question probably exists a way how to pass string like that in mapping?
Copy code
//x00//x00//x00//x00//x15{"message":"Hello"}"
@Tom sorry for bothering😊
t

Tom

02/26/2024, 4:17 PM
Did you remove the
headers
element completely or null the value?
t

TheUsharik

02/26/2024, 4:41 PM
I remove it completely like it was in the example
Also if I try anything not like
application/grpc
or
application/grpc+...
I'm getting same error
t

Tom

02/26/2024, 5:11 PM
I think I’d need a reproducer project to make any more progress with this. I can’t see anything obviously wrong with what you’re attempting.
t

TheUsharik

02/26/2024, 5:50 PM
Hm... I will try... But may I ask a bit different thing. As far as I know gRPC is a binary format and as I can see from Wireshark logs all my gRPC servers are sending binary code which is not looks like JSON. But as far as I can see the Wiremock in gRPC mode is operating with JSON. Where I'm wrong here?
t

Tom

02/26/2024, 5:51 PM
The WireMock extension converts the JSON response you specify in the stub to protobuf
So the JSON never actually gets sent anywhere, it’s just a way of specifying the data you want
t

TheUsharik

02/26/2024, 6:22 PM
Looks like I found a way to reproduce! If in examples from here https://github.com/wiremock/wiremock-grpc-demos/tree/main You will change gRPC server implementation to
Copy code
testImplementation("io.grpc:grpc-netty:1.61.1")
You will get same error as me. UPDATE: It's about the gRPC version. If I downgrade to 1.59.0 it works also with Netty implementation. If you don't mind I can try to fix that.
t

Tom

02/26/2024, 6:55 PM
That would be much appreciated!
t

TheUsharik

02/27/2024, 2:39 PM
Sorry that was my fault. I used wiremock-grp-extension instead of wiremock-grap-extension-standalone
t

Tom

02/27/2024, 2:49 PM
Ah, that’ll be it then 🙂
54 Views