doujiang24 / lua-resty-kafka

Lua kafka client driver for the Openresty based on the cosocket API
BSD 3-Clause "New" or "Revised" License
804 stars 275 forks source link

Getting error when sending message #4

Closed peterneubauer closed 8 years ago

peterneubauer commented 9 years ago

Hi there, I'm trying to use this module but get errors like below. Do you have any idea why this is? This "domain-test" topic should be existing on my broker.

2014/12/17 10:37:55 [error] 32594#0: *31 lua entry thread aborted: runtime error: /usr/share/lualib/resty/kafka/request.lua:167: 'for' limit must be a number
stack traceback:
coroutine 0:
        /usr/share/lualib/resty/kafka/request.lua: in function 'message_set'
        /usr/share/lualib/resty/kafka/producer.lua:76: in function 'produce_encode'
        /usr/share/lualib/resty/kafka/producer.lua:248: in function 'send'
        /etc/nginx/lua/info_tests.lua:42: in function </etc/nginx/lua/info_tests.lua:1>, 

with info-tests.lua being something like this (line numbers are not correct):


local cjson = require "cjson"
local producer = require "resty.kafka.producer"

local broker_list = {
  { host = "xxxx", port = xxx },
}

local key = "key"
local message = "halo world"

local bp = producer:new(broker_list, { producer_type = "async" })

local size, err = bp:send("domain-test", key, message)
if not size then
  ngx.say("send err:", err)
  return
end
doujiang24 commented 9 years ago

sorry, this library is under early development and it changed many in these days, I found that you are using the old code, but you use it like the master branch README. So, you are recommended to use the master branch, it also passed all my test cases in the directory t.

doujiang24 commented 8 years ago

Consider it resolved.