Unable to use MQTT library example

I am using the callbacks.pl example which comes with MQTT pack when downloaded from official website. I have installed MQTT library in my Ubuntu 18 system by pack_install(). Then on using simple_sub(), I am facing this issue which traces to the function c_mqtt_connect(). I am unable to understand the error. Please help me.

For online help and background, visit [https://www.swi-prolog.org](https://www.swi-prolog.org/)
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- consult('callbacks.pl').
true.

?- gtrace, simple_pub(Temp,27).
% The graphical front-end will be used for subsequent tracing

SWI-Prolog [thread 1 (main) at Wed Feb 10 13:57:33 2021]: received fatal signal 11 (segv)
C-stack trace labeled "crash":
[0] PL_strtod() at ??:? [0x7fe57cb87268]
[1] bstore_print_backtrace_named() at ??:? [0x7fe57cb8741e]
[2] bstore_print_backtrace_named() at ??:? [0x7fe57cb8753f]
[3] PL_get_signum_ex() at ??:? [0x7fe57cb14103]
[4] killpg() at ??:? [0x7fe57c6bd040]
[5] __GI___libc_free() at /build/glibc-S7xCS9/glibc-2.27/malloc/malloc.c:3113 [0x7fe57c715a6d]
[6] c_mqtt_connect() at /home/olozyns/prolog_src/my_packs/swi-mqtt-pack/c/mqtt.c:1074 [0x7fe57a4c390d]
[7] PL_next_solution() at ??:? [0x7fe57caacac4]
[8] pl_skip_list3_va() at ??:? [0x7fe57caf95f4]
[9] pl_skip_list3_va() at ??:? [0x7fe57caf9e9b]
[10] PL_toplevel() at ??:? [0x7fe57caa58bd]
[11] prolog(+0x7c5) [0x56209c0e07c5]
[12] __libc_start_main() at /build/glibc-S7xCS9/glibc-2.27/csu/../csu/libc-start.c:344 [0x7fe57c69fbf7]
[13] prolog(+0x80a) [0x56209c0e080a]
Prolog stack:
[13] mqtt:c_mqtt_connect/4 [PC=1 in supervisor]
[12] mqtt:mqtt_connect/4 [PC=33 in clause 1]
[11] simple_pub/2 [PC=95 in clause 1]
[10] system:/1 [PC=7 in clause -1]
[9] $toplevel:toplevel_call/1 [PC=3 in clause 1]
[8] $toplevel:stop_backtrace/1 [PC=4 in clause 1]
[7] $tabling:$wfs_call/2 [PC=17 in clause 1]
[5] $toplevel:$execute_goal2/3 [PC=29 in clause 1]
[3] $toplevel:$query_loop/0 [PC=39 in clause 2]
[2] $toplevel:$runtoplevel/0 [PC=19 in clause 1]
[1] $toplevel:$toplevel/0 [PC=3 in clause 1]
[0] system:$c_call_prolog/0 [PC=0 in top query clause]
Running on_halt hooks with status 139
Killing 3518 with default signal handlers
Segmentation fault (core dumped)

Wow, I didn’t know anyone else was trying MQTT with Prolog these days. The mqtt pack from the official website has some issues and doesn’t appear to be under active development by the original author so I’ve been working on it. Nothing to release quite yet, but my fork is at GitHub - sprior/swi-mqtt-pack: MQTT pack for SWI-Prolog though I’ve been working on some fixes this last week which aren’t there yet.

In any case I’m not as familiar with the original examples, but have you installed the mosquitto broker (not just the client library) on your local machine and/or changed from localhost to the IP of your broker in your example code?

Not yet. Currently I am trying to connect on localhost.

If you don’t have a mosquitto broker installed on localhost it’s not going to work.