Skip to content

bug: PubSub/Kafka protobuf decode error when sending response #10938

Description

@arnauddeman

Current Behavior

I use pubsub to connect apisix to kafka. I succeeded to create a route, to connect to it via websocket and to send a PubSubReq query. The messages are correctly fetched from kafka but then this error is thrown when apisix try to send the response: bad argument #​1 to '?' (type 'PubSubResp' does not exists)

I believe this is a pb state problem and adding this instruction
local pb_old_state = pb.state(pb_state)
at the beginning of send_resp in pubsub.lua fixed the issue for me.

I am not very familiar with protobuf so I am not sure if this instruction is actually missing or if there is an error on my side.

Expected Behavior

Response should be encoded successfully as the type PubSubResp is defined in pubsub.proto

Error Logs

send_resp(): failed to encode response message, err: bad argument #​1 to '?' (type 'PubSubResp' does not exists), client: 172.22.0.1, server: _, request: "GET /kafka HTTP/1.1", host: "localhost:9080"

Steps to Reproduce

1 - Create a route to connect to KAFKA Broker.
2 - Subscribe to this route via web socket.
3 - Send a PubSubReq to a topic with partition and offset in order that Apisix recieve Kafka messages.
4 - The send_response function should fail to encode the response message.

Environment

APISIX docker version, image apache/apisix:3.6.0-debian

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions