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

fix: broker 'UNSUPPORTED_VERSION' problem arising from 'api_version' #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Niubility-Wen
Copy link

Hello, I am having some problems sending messages to different versions of kafka:

  1. test dev: opresty-1.21.4.3 + kafka 3.7.0 + lua-resty-kafka latest
  • Do not set 'api_version' in 'client_config'
  • All is well
  1. pro dev: opresty-1.21.4.3 + kafka 1.1.0 + lua-resty-kafka latest
  • An 'UNSUPPORTED_VERSION' error is reported regardless of whether the 'api_version' in 'client_config' is set to 0, 1, or 2

I found that the 'api_version' parameter in line 49 and 118 of client.lua is hard code

local function metadata_encode(client_id, topics, num)
    local id = 0    -- hard code correlation_id
    local req = request:new(request.MetadataRequest, id, client_id, request.API_VERSION_V1)

    req:int32(num)

    for i = 1, num do
        req:string(topics[i])
    end

    return req
end
local function api_versions_encode(client_id)
    local id = 1    -- hard code correlation_id
    return request:new(request.ApiVersionsRequest, id, client_id, request.API_VERSION_V2)
end

I have made some changes to client.lua to achieve better compatibility between client and broker

@yuqiquan
Copy link

I also encountered the same issue with Kafka version 1.x. By modifying the code as described above and setting api_version to 1, I was able to send messages to Kafka normally. As of today, it seems the latest version 0.23 has not adopted this code. I'm a bit confused now:

  1. What problems might arise from this change, and why hasn't it been adopted?
  2. Why are the versions hardcoded in some places within client.lua, with one being v1 and another being v2?

image
image

Please help me understand this, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants