Not able to connect to local mosquito broker instance

I am trying demo (FreeRTOSv202012.00\FreeRTOS-Plus\Demo\coreMQTT_Windows_Simulator\MQTT_Plain_Text) on my windows PC.
I am able to connect with test.mosquito.org but not with local installed mosquito broker.
Getting timeout error (116) with freertos_connect().
What settings required to be done?

You need to edit mosquitto.conf to set the network interface and port number Mosquitto will listen on. Here is an exert from the file on my machine. Note I set a high port number because otherwise the firewall blocks the connection:

#bind the default listener to. If not
# given, the default listener will not be bound to a specific
# address and so will be accessible to all network interfaces.
# bind_address ip-address/host name
bind_address 192.168.0.28

# Port to use for the default listener.
# port 1883
port 50000

Then you need to set the same information in the demo_config.h file within the FreeRTOS project.

/**
 * @brief MQTT broker end point to connect to.
 *
 * @note If you would like to setup an MQTT broker for running this demo,
 * please see `mqtt_broker_setup.txt`.
 *
 * #define democonfigMQTT_BROKER_ENDPOINT				"192.168.0.28"
 */


/**
 * @brief The port to use for the demo.
 *
 * #define democonfigMQTT_BROKER_PORT					50000
 */

Note we are also working on some examples that use an MQTT agent to provide full multithreading within this repo: https://github.com/FreeRTOS/Lab-Project-coreMQTT-Agent

Thanks for the reply.
I tried the same but still getting errors.
Below is the log.

The interface that will be opened is set by “configNETWORK_INTERFACE_TO_USE”, which
should be defined in FreeRTOSConfig.h
Attempting to open interface number 7.
Successfully opened interface number 7.
0 348 [IP-task] vDHCPProcess: offer 192.168.0.105
vDHCPProcess: offer 192.168.0.105
1 668 [IP-task] [INFO] [MQTTDemo] [vApplicationIPNetworkEventHook:190] ---------STARTING DEMO---------

2 668 [IP-task] [INFO] [MQTTDemo] [vApplicationIPNetworkEventHook:199]

IP Address: 192.168.0.105

3 668 [IP-task] [INFO] [MQTTDemo] [vApplicationIPNetworkEventHook:202] Subnet Mask: 255.255.255.0

4 668 [IP-task] [INFO] [MQTTDemo] [vApplicationIPNetworkEventHook:205] Gateway Address: 192.168.0.1

5 668 [IP-task] [INFO] [MQTTDemo] [vApplicationIPNetworkEventHook:208] DNS Server Address: 192.168.0.1

6 668 [DemoTask] [INFO] [MQTTDemo] [prvConnectToServerWithBackoffRetries:514] Create a TCP connection to 192.168.0.107:56000.
7 5668 [DemoTask] [ERROR] [Sockets] [Sockets_Connect:102] Failed to connect to server: FreeRTOS_Connect failed: ReturnCode=-116, Hostname=192.168.0.107, Port=56000.
8 5668 [DemoTask] [ERROR] [Sockets] [Plaintext_FreeRTOS_Connect:93] Failed to connect to 192.168.0.107 with error -116.
9 5668 [DemoTask] [WARN] [MQTTDemo] [prvConnectToServerWithBackoffRetries:537] Connection to the broker failed. Retrying connection with backoff and jitter.

So the connection is timing out.

I know some people have problems connecting to echo servers that are running on the same machine as the FreeRTOS app - maybe this is the same issue (which I don’t have myself). Can you try running Mosquitto on a different computer on the same network?

Another tip is to try using a third party MQTT client to try the connection first to make sure that can connect successfully. I use https://mqttfx.jensd.de/