Closed gavin0505 closed 5 months ago
本地Kafka已经创建过test的Topic,并且能正常工作。但是无法通过OpenResty向其发送信息。设置同步发送信息则会报错:4kafka send err:not found topic;设置异步发送消息,后面的Lua可以跑通,但是Kakfa依然无法接收消息。
版本 OpenResty: 1.21.4.2 Kafka: 3.2.x 操作系统:MacOS 12.7.1
local producer = require "resty.kafka.producer" local cjson = require "cjson" local content = {} content["hello"] = "world" local broker_list = { {host = "localhost", port = 9092}, } local kafka_topic = "test" local producer = producer:new(broker_list, { producer_type = "sync", request_timeout = 1000, max_retry = 3, socket_timeout = 1000 }) local msg = cjson.encode(content) local offset, err = producer:send(kafka_topic, nil, msg) if not offset then ngx.say(ngx.ERR, 'kafka send err:', err) elseif offset then ngx.say("the message send successful") else ngx.say("未知错误") end
似乎是我OpenResty版本的问题。降到1.15.8.2就好了。
本地Kafka已经创建过test的Topic,并且能正常工作。但是无法通过OpenResty向其发送信息。设置同步发送信息则会报错:4kafka send err:not found topic;设置异步发送消息,后面的Lua可以跑通,但是Kakfa依然无法接收消息。
版本 OpenResty: 1.21.4.2 Kafka: 3.2.x 操作系统:MacOS 12.7.1