我基于alpine linux构建了一个docker容器。我尝试使用symfony messenger向外部kafka代理发送消息。
这是我的信使配置:
messenger:
transports:
de_fadi_criminal_charges_public_criminal_charge_created:
dsn: '%env(KAFKA_DSN)%'
serializer: AppSerializerAvroCriminalChargeCreatedSerializer
options:
flushTimeout: 10000
flushRetries: 5
topic:
name: 'de.fadi.criminal_charges.public.criminal_charge_created'
kafka_conf:
security.protocol: 'sasl_ssl'
ssl.ca.location: '%kernel.project_dir%/config/kafka/ca.pem'
sasl.username: '%env(KAFKA_SASL_USERNAME)%'
sasl.password: '%env(KAFKA_SASL_PASSWORD)%'
sasl.mechanism: 'PLAIN'
,这些是我的Docker文件中的相关行:
ARG LIBRDKAFKA_GIT_SHA1=1f7417d4796e036b8c19f17373f8290ff5c7561f
RUN apk add --update --no-cache alpine-sdk bash python autoconf openssl
&& git clone -o ${LIBRDKAFKA_GIT_SHA1} https://github.com/edenhill/librdkafka.git /tmp/librdkafka
&& cd /tmp/librdkafka/
&& ./configure
&& make
&& make install
当我在构建后检查Open SSL是否可用时,我得到这个:
$ openssl version
OpenSSL 1.1.1l 24 Aug 2021
当我尝试发送消息到配置的服务器时,我得到这个错误消息:
不支持值"sasl_ssl"对于配置属性"security.protocol": OpenSSL在构建时不可用
我找到的所有答案都指向这样一个事实:你必须先安装openssl,然后像我那样构建rdkafka。我错过了什么?
正如@dave_thompson_085指出的那样,如果要使用openssl库来构建软件,那么包含openssl库是不够的
将openssl替换为openssl-dev就成功了:
RUN apk add --update --no-cache alpine-sdk bash python autoconf openssl-dev
&& git clone -o ${LIBRDKAFKA_GIT_SHA1} https://github.com/edenhill/librdkafka.git /tmp/librdkafka
&& cd /tmp/librdkafka/
&& ./configure
&& make
&& make install