Ошибка Mqtt «Программное обеспечение вызвало прерывание соединения»C++

Программы на C++. Форум разработчиков
Anonymous
Ошибка Mqtt «Программное обеспечение вызвало прерывание соединения»

Сообщение Anonymous »

Я пытаюсь отправить данные из nodemcu(esp32) в Raspberry Pi с помощью mqtt. После подключения к сети Wi-Fi возникает эта ошибка. Ошибка: попытка подключения MQTT...[E][WiFiClient.cpp:365] write(): сбой на fd 55, ошибка: 113, «Программное обеспечение вызвало прерывание соединения»
не удалось, rc=-4 повторите попытку через 5 секунд
Nodemcu не удается подключиться к брокеру mosquitto mqtt, работающему на Raspberry Pi. Я попытался проверить, открыт ли порт 1883 и есть ли какие-либо проблемы с брокером rpi mqtt. Никаких проблем там не нашел. Пробовал несколько библиотек. Но результат остается прежним.
Это код, который я использую:
#include "EspMQTTClient.h"

EspMQTTClient client(
"XXXXX",
"XXXXX",
"XXXXXX", // MQTT Broker server ip
// Can be omitted if not needed
// Can be omitted if not needed
"TestClient", // Client name that uniquely identify your device
1883 // The MQTT port, default to 1883. this line can be omitted
);

void setup()
{
Serial.begin(9600);

// Optional functionality of EspMQTTClient :
client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
client.enableHTTPWebUpdater(); // Enable the web updater. User and password default to values of MQTTUsername and MQTTPassword. These can be overrited with enableHTTPWebUpdater("user", "password").
client.enableLastWillMessage("TestClient/lastwill", "I am going offline"); // You can activate the retain flag by setting the third parameter to true
}

// This function is called once everything is connected (Wifi and MQTT)
// WARNING : YOU MUST IMPLEMENT IT IF YOU USE EspMQTTClient
void onConnectionEstablished()
{
// Subscribe to "mytopic/test" and display received message to Serial
client.subscribe("refrigerator/temp", [](const String & payload) {
Serial.println(payload);
});

// Publish a message to "mytopic/test"
client.publish("refrigerator/temp", "Temp=34"); // You can activate the retain flag by setting the third parameter to true

// Execute delayed instructions
client.executeDelayed(5 * 1000, []() {
client.publish("refrigerator/temp", "Temp=23");
});
}

void loop()
{
client.loop();
}



Подробнее здесь: https://stackoverflow.com/questions/566 ... bort-error

Вернуться в «C++»