Why i cant connect to my own build mqtt broker in esp8266?

If you are asking a question, please follow this template:

  1. I want to make my esp8266 act as a mqtt broker, but i cant connect to it. i dont know why i cant connect it, i already change the port in mqttbox to ip that provided by my mqtt broker(esp8266).
  2. here is my code :
#include "mongoose.h"


static const char *address = "";

static void ev_handler(struct mg_connection *c, int ev, void *ev_data) {
  if (ev != MG_EV_POLL) printf("USER HANDLER GOT EVENT %d\n", ev);
  /* Do your custom event processing here */
  mg_mqtt_broker(c, ev, ev_data);

int main(void) {
  struct mg_mgr mgr;
  struct mg_connection *c;
  struct mg_mqtt_broker brk;

  mg_mgr_init(&mgr, NULL);

  if ((c = mg_bind(&mgr, address, ev_handler)) == NULL) {
    fprintf(stderr, "mg_bind(%s) failed\n", address);
  mg_mqtt_broker_init(&brk, NULL);
  c->priv_2 = &brk;

  printf("MQTT broker started on %s\n", address);

   * TODO: Add a HTTP status page that shows current sessions
   * and subscriptions

  for (;;) {
    mg_mgr_poll(&mgr, 1000);

src : https://github.com/cesanta/mongoose/blob/master/examples/mqtt_broker/mqtt_broker.c

4. can someone help me to solve this? thanks

The mqtt-broker is not included in the Mongoose OS build.

It is only available for applications which use the “standalone” Mongoose - Embedded Web Server / Embedded Networking Library

The version used by Mongoose OS does not enable the mqtt-broker.

hello again nliviu and thanks for helping me again :smiley:

what is that mean with “standalone” , can u give me some example?
i didnt understand because i still newbie with mongoose haha

By “standalone” I mean a program compiled for Windows, Linux, or other platforms like the ones from the examples.

oh ok, so mqtt broker is only available in https://github.com/cesanta/mongoose and if i want to use mqtt broker i need to copy mongoose.c and mongoose.h to my build trees then what?

No, it won’t work.
The library mongoose is pulled in by default and it does not enable the mqtt-broker.

yeah , i already try that
so is there any another way to use mqtt broker in mongoose? or its hopeless to use mqtt broker on mongoose? , i mean like if by default mongoose os does not have a mqtt broker libs , how can i even enable the mqtt broker haha.

You have to use a mqtt-broker installed somewhere else in your LAN.
mosquitto is a very good choice.

how do we apply that? does you have any examples?