Skip to content

Commit 4a828ab

Browse files
authored
update paho mqtt lib to 1.3.14 (#80)
* update paho mqtt lib to 1.3.14 * change how paho mqtt build from linux dependant paho mqtt lib now uses a very recent version of glibc in the provided pre-build package. now building from source to prevent errors such as '/lib64/libc.so.6: version `GLIBC_2.38' not found (required by /source/paho.mqtt.c/lib/libpaho-mqtt3c.so.1)
1 parent c0a2714 commit 4a828ab

File tree

7 files changed

+37
-42
lines changed

7 files changed

+37
-42
lines changed

docker_linux/Dockerfile.alpine

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN mkdir -p /source/mqtt/include
1010
COPY docker_linux/mqtt_build.sh /source
1111

1212
COPY CMakeLists.txt /source/mqtt
13-
COPY docker_linux/build_libpaho.sh /source/mqtt
13+
COPY docker_linux/build_libpaho.sh /source/
1414
COPY install.sh /source/mqtt
1515
COPY README.md /source/mqtt
1616
COPY LICENSE /source/mqtt
@@ -35,13 +35,13 @@ RUN apk add --update && \
3535
apk add gcompat && \
3636
apk add libnsl && \
3737
cd /source && \
38-
/bin/sh /source/mqtt/build_libpaho.sh && \
38+
/bin/sh build_libpaho.sh && tar xvf Eclipse-Paho*.tar.gz -C ./paho.mqtt.c --strip-components=1 && \
3939
apk del gcc && \
4040
apk del cmake && \
4141
apk del make && \
4242
apk del wget && \
4343
apk del build-base && \
44-
rm -rf /source/mqtt_build.sh /source/paho.mqtt.c /source/v1.3.13* /source/mqtt/CmakeLists.txt
44+
rm -rf /source/mqtt_build.sh /source/paho.mqtt.c /source/v1.3.14* /source/mqtt/CmakeLists.txt
4545

4646
## Update this section here to add kdb+
4747
#COPY q/k4.lic /q/

docker_linux/Dockerfile.centos7

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ ENV QHOME /q
2121
ENV PATH /q/l64:$PATH
2222
ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH
2323

24-
RUN cd /source && wget https://github.com/eclipse/paho.mqtt.c/releases/download/v1.3.13/Eclipse-Paho-MQTT-C-1.3.13-Linux.tar.gz && tar xvf Eclipse-Paho-MQTT-C-1.3.13-Linux.tar.gz -C ./paho.mqtt.c --strip-components=1
24+
RUN cd /tmp/ && wget https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz && tar zxvf cmake-3.* && cd cmake-3.* && ./bootstrap --prefix=/usr/local && make && make install && rm /tmp/cmake-3.12.3.tar.gz
25+
RUN yum -y install epel-release && yum -y install mosquitto
26+
27+
COPY build_libpaho.sh /source/
28+
RUN cd /source && /bin/sh build_libpaho.sh
29+
RUN cd /source && tar xvf Eclipse-Paho*.tar.gz -C ./paho.mqtt.c --strip-components=1
2530
ENV BUILD_HOME /source/paho.mqtt.c
2631

2732
COPY mqtt_build.sh /source
2833
RUN chmod u+x /source/mqtt_build.sh && /source/mqtt_build.sh
2934

30-
RUN cd /tmp/ && wget https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz && tar zxvf cmake-3.* && cd cmake-3.* && ./bootstrap --prefix=/usr/local && make && make install && rm /tmp/cmake-3.12.3.tar.gz
31-
RUN yum -y install epel-release && yum -y install mosquitto
32-
3335
WORKDIR /source
3436

3537
CMD ["/bin/bash"]

docker_linux/build_libpaho.sh

+7-26
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
11
#!/bin/sh
2-
3-
cd /source
42

5-
wget https://github.com/eclipse/paho.mqtt.c/archive/refs/tags/v1.3.13.tar.gz
6-
tar xvf v1.3.13.tar.gz -C ./paho.mqtt.c --strip-components=1
7-
8-
cd paho.mqtt.c
9-
10-
# This library is not present in the Alpine image, removing it from the compiler args
11-
sed -i 's/GAI_LIB = -lanl/#GAI_LIB = -lanl/g' Makefile
12-
ln -s /usr/lib/libnsl.so.2 /usr/lib/libnsl.so.1
13-
14-
make
15-
make install
16-
mkdir -p include/lib
17-
cd include/lib
18-
19-
ln -s /usr/local/lib/libpaho-mqtt3c.so libpaho-mqtt3c.a
20-
ln -s /usr/local/lib/libpaho-mqtt3cs.so libpaho-mqtt3cs.a
21-
ln -s /usr/local/lib/libpaho-mqtt3as.so libpaho-mqtt3as.a
22-
ln -s /usr/local/lib/libpaho-mqtt3a.so libpaho-mqtt3a.a
23-
24-
mkdir /source/mqtt/cmake
25-
cd /source/mqtt/cmake
26-
cmake ..
27-
make
28-
make install
3+
OLD_DIR=`pwd`
4+
mkdir /tmp/paho && cd /tmp/paho
5+
wget https://github.com/eclipse-paho/paho.mqtt.c/archive/refs/tags/v1.3.14.tar.gz -O paho_src.tar.gz
6+
mkdir paho_src && tar xvf paho_src.tar.gz -C ./paho_src --strip-components=1 && cd paho_src
7+
mkdir build && cd build
8+
cmake -DPAHO_BUILD_STATIC=FALSE -DPAHO_BUILD_SHARED=TRUE -DCMAKE_BUILD_TYPE=Release -DPAHO_WITH_SSL=TRUE -DOPENSSL_ROOT_DIR= -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=FALSE -DPAHO_HIGH_PERFORMANCE=TRUE -DCMAKE_INSTALL_LIBDIR=lib .. && cmake --build . && cpack --verbose
9+
cp Eclipse*.tar.gz $OLD_DIR && rm -rf /tmp/paho

docs/install.md

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
## Installing a release
1212

1313
1. Ensure [MQTT C API](https://github.com/eclipse/paho.mqtt.c/releases) (`paho.mqtt.c`) is installed.
14+
15+
- Linux: Paho MQTT provides a pre-build binary which may be built against a more recent version of glibc that may be available on your system, resulting in an error such as `'/lib64/libc.so.6: version `GLIBC_2.38' not found`. To get around this, build from the paho mqtt library from the source code package. See docker_linux/build_libpaho.sh as an example of how to download and build into a `tar.gz` package.
16+
1417
2. Make the MQTT library available from kdb+:
1518

1619
- Linux: Add the `lib` directory, which includes `include` and `lib` to the `LD_LIBRARY_PATH` environment variable e.g. if unzipped to `/usr/local/Eclipse-Paho-MQTT-C/`, run:

docs/reference.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,25 @@ The underlying Paho Mqtt C lib provides the ability to route traffic through a w
7777
These can be set using standard web proxy environment variables or parameters per connection.
7878
Format can be `http(s)://user:[email protected]:port` or `ip:port`.
7979

80+
Since Paho Mqtt v1.3.14, the environment variable `PAHO_C_CLIENT_USE_HTTP_PROXY` must be set to `TRUE` in order to
81+
use environment variables for proxy settings.
82+
8083
If multiple options defined, the http proxy configuration are listed below in descending precendence:
8184

8285
1. [Connection option](#general-connection-options) `httpProxy`
8386
2. Environment variable `mqtt_http_proxy`
8487
3. Environment variable `http_proxy`
8588

86-
and for https (TLS/SSL) proxy configuration:
89+
, for https (TLS/SSL) proxy configuration:
8790

8891
1. [Connection option](#general-connection-options) `httpsProxy`
8992
2. Environment variable `mqtt_https_proxy`
9093
3. Environment variable `https_proxy`
9194

92-
To prevent mqtt from using any proxy, when http_proxy/https_proxy is being used by another application, set the following on linux/macOS `export mqtt_http_proxy=` or on windows
93-
set to a space (blank character) `set mqtt_http_proxy= `
95+
and for `no_proxy` configuration:
96+
97+
1. Environment variable `mqtt_no_proxy`
98+
2. Environment variable `no_proxy`
9499

95100
### General Connection Options
96101

src/mqtt.c

+4
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ static void restoreProxyEnv(const char* sys,const char* sysval){
127127
EXP K connX(K tcpconn,K pname, K opt){
128128
static const char* HTTP_PROXY="http_proxy";
129129
static const char* HTTPS_PROXY="https_proxy";
130+
static const char* NO_PROXY="no_proxy";
130131
const char* system_proxy=getenv(HTTP_PROXY);
131132
const char* system_proxys=getenv(HTTPS_PROXY);
133+
const char* system_noproxy=getenv(NO_PROXY);
132134
int err;
133135
if(tcpconn->t != -KS)
134136
return krr("addr type");
@@ -233,9 +235,11 @@ EXP K connX(K tcpconn,K pname, K opt){
233235

234236
setProxyEnv(HTTP_PROXY,system_proxy,getenv("mqtt_http_proxy")); /* replace http_proxy setting with mqtt_http_proxy if available */
235237
setProxyEnv(HTTPS_PROXY,system_proxys,getenv("mqtt_https_proxy")); /* replace https_proxy setting with mqtt_https_proxy if available */
238+
setProxyEnv(NO_PROXY,system_noproxy,getenv("mqtt_no_proxy")); /* replace https_proxy setting with mqtt_https_proxy if available */
236239
err = MQTTClient_connect(client, &conn_opts);
237240
restoreProxyEnv(HTTP_PROXY,system_proxy);
238241
restoreProxyEnv(HTTPS_PROXY,system_proxys);
242+
restoreProxyEnv(HTTPS_PROXY,system_noproxy);
239243

240244
freeOpts(&conn_opts);
241245

travis_setup.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
mkdir cbuild
44

55
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
6-
wget https://github.com/eclipse/paho.mqtt.c/releases/download/v1.3.13/Eclipse-Paho-MQTT-C-1.3.13-Darwin.tar.gz
7-
tar xvf Eclipse-Paho-MQTT-C-1.3.13-Darwin.tar.gz -C ./cbuild --strip-components=1
6+
wget https://github.com/eclipse-paho/paho.mqtt.c/releases/download/v1.3.14/Eclipse-Paho-MQTT-C-1.3.14-Darwin.tar.gz
7+
tar xvf Eclipse-Paho-MQTT-C-1.3.14-Darwin.tar.gz -C ./cbuild --strip-components=1
88
elif [ "$TRAVIS_OS_NAME" == "linux" ]; then
9-
wget https://github.com/eclipse/paho.mqtt.c/releases/download/v1.3.13/Eclipse-Paho-MQTT-C-1.3.13-Linux.tar.gz
10-
tar xvf Eclipse-Paho-MQTT-C-1.3.13-Linux.tar.gz -C ./cbuild --strip-components=1
9+
/bin/sh docker_linux/build_libpaho.sh
10+
tar xvf Eclipse-Paho-MQTT-C-1.3.14-Linux.tar.gz -C ./cbuild --strip-components=1
1111
elif [ "$TRAVIS_OS_NAME" == "windows" ]; then
12-
wget https://github.com/eclipse/paho.mqtt.c/releases/download/v1.3.13/eclipse-paho-mqtt-c-win64-1.3.13.zip
13-
7z x -ocbuild eclipse-paho-mqtt-c-win64-1.3.13.zip
12+
wget https://github.com/eclipse-paho/paho.mqtt.c/releases/download/v1.3.14/eclipse-paho-mqtt-c-win64-1.3.14.zip
13+
7z x -ocbuild eclipse-paho-mqtt-c-win64-1.3.14.zip
1414
else
1515
echo "$TRAVIS_OS_NAME is currently not supported"
1616
fi

0 commit comments

Comments
 (0)