Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arnauddeman opened this issue Feb 16, 2024 · 5 comments · Fixed by #11135
Closed

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

arnauddeman opened this issue Feb 16, 2024 · 5 comments · Fixed by #11135
Labels
bug Something isn't working

Comments

@arnauddeman
Copy link

arnauddeman commented Feb 16, 2024

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

@shreemaan-abhishek
Copy link
Contributor

I would like to try to repro this issue but I am not much familiar with kafka, so could you please help me with a self contained example?

@shreemaan-abhishek shreemaan-abhishek added the bug Something isn't working label Feb 25, 2024
@arnauddeman
Copy link
Author

I can create a Github project with docker-compose files and some node scripts.
Would it be OK for you ?

@shreemaan-abhishek
Copy link
Contributor

sure

@arnauddeman
Copy link
Author

The repository is: https://github.com/arnauddeman/APISIX-Kafka
The explanations are in the Readme file, but let me know if it is not clear or if there is an issue.
I use Linux, you may have to adapt the npm scripts if your OS is not unix based.

@shreemaan-abhishek
Copy link
Contributor

I could reproduce this bug. The reason why this bug occurs is that the pb.state is lost in between init and sent_resp. I have raised this PR to fix the bug: #11135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants