You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hi,
this may be related to #16
but I couldn't try this yet.
My issue:
I've successfully got the broker running on a esp8266 / Arduino.
One can connect from other (Linux or Raspi) boxes flawlessly and use the broker (tried with mosquitto clients)
However connecting a client from the very same esp8266 won't connect - the client stays in stat 'TCP_CONNECTING' (state 12, see below).
I've tried to connect to '127.0.0.1' or the local IP (see below) - no difference.
Interesting is that if I let the esp8266 client connect to another broker (on a RPi) in my network it works as expected and the published messages are processed.
I wonder how the 'localhost' path can be any different - but I'm not really an expert on IP programming.
I've tried the 'fix' from the other post to add 'WiFi.mode(WIFI_STA)' ... but this didn't change anything.
Note that I'm using the 'AutoConnect' library to get the IP from the nvs, or offer the Wifi selection webserver on bootstrap + some goodies like OTA. All this works nicely. So the general IP connectivity (from outside) seems to be there.
Any hints would be very much appreciated.
thx, pottendo
Here the debug log:
[...]
Setting up Wifi...done.
Setting up local time...Sun Dec 6 20:00:10 2020
Setting hostname fcce
Starting MQTT broker
Starting MQTT server on port 1883
MQTT:InitConnection
MQTT:InitClient
connect mqtt client...
MQTT: Client task activated - state 0
TCP: Connect to ip 192.168.188.34:1883
MQTT: queue subscribe, topic"/mytopic", id: 1
MQTT: Client task activated - state 12
MQTT: queuing publish, length: 26, queue size(17/2048)
MQTT: Client task activated - state 12
MQTT: queuing publish, length: 26, queue size(45/2048)
MQTT: Client task activated - state 12
[...]
hi,
as I stumbled over the '5x connection and then connection error' issue as well, I've activated lwip <2!
Still no success (but 5+ connections possible) BUT with changing the client connecting from '127.0.0.1' (or "localhost") to the real IP address ('WiFi.localIO()') it works like a charm!
my code now:
[...]
mqtt_client = new MQTT{my_clientID.c_str(), WiFi.localIP().toString().c_str(), 1883};
[...]
Note that I'm using PlatformIO and here activating lwip 1.x one needs to add
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
in platformio.ini
However then build failed in my setup with some 'ipv4_addr_t' being undefined.
I 'fixed' that by adding the typedef myself to
~/.platformio/packages/framework-arduinoespressif8266/tools/sdk/include/ipv4_addr.h
[...]
///////////////////////////////////////////////
#if LWIP_VERSION_MAJOR == 1
hi,
this may be related to
#16
but I couldn't try this yet.
My issue:
I've successfully got the broker running on a esp8266 / Arduino.
One can connect from other (Linux or Raspi) boxes flawlessly and use the broker (tried with mosquitto clients)
However connecting a client from the very same esp8266 won't connect - the client stays in stat 'TCP_CONNECTING' (state 12, see below).
I've tried to connect to '127.0.0.1' or the local IP (see below) - no difference.
Interesting is that if I let the esp8266 client connect to another broker (on a RPi) in my network it works as expected and the published messages are processed.
I wonder how the 'localhost' path can be any different - but I'm not really an expert on IP programming.
I've tried the 'fix' from the other post to add 'WiFi.mode(WIFI_STA)' ... but this didn't change anything.
Note that I'm using the 'AutoConnect' library to get the IP from the nvs, or offer the Wifi selection webserver on bootstrap + some goodies like OTA. All this works nicely. So the general IP connectivity (from outside) seems to be there.
Any hints would be very much appreciated.
thx, pottendo
Here the debug log:
[...]
Setting up Wifi...done.
Setting up local time...Sun Dec 6 20:00:10 2020
Setting hostname fcce
Starting MQTT broker
Starting MQTT server on port 1883
MQTT:InitConnection
MQTT:InitClient
connect mqtt client...
MQTT: Client task activated - state 0
TCP: Connect to ip 192.168.188.34:1883
MQTT: queue subscribe, topic"/mytopic", id: 1
MQTT: Client task activated - state 12
MQTT: queuing publish, length: 26, queue size(17/2048)
MQTT: Client task activated - state 12
MQTT: queuing publish, length: 26, queue size(45/2048)
MQTT: Client task activated - state 12
[...]
and the code (follows pretty much the example):
[...]
void setup_mqtt(void)
{
delay(100);
mqtt_client = new MQTT{my_clientID.c_str(), "192.168.188.34" /WiFi.localIP().toString().c_str()/, 1883};
// setup callbacks
mqtt_client->onConnected(myConnectedCb);
mqtt_client->onDisconnected(myDisconnectedCb);
mqtt_client->onPublished(myPublishedCb);
mqtt_client->onData(myDataCb);
log_msg("connect mqtt client...");
delay(100);
mqtt_client->connect();
delay(100);
mqtt_client->subscribe("/mytopic");
}
void mqtt_publish(String topic, String msg)
{
//log_msg("publishing: " + my_clientID + topic + msg);
mqtt_client->publish(my_clientID + topic, msg, 0, 0);
}
The text was updated successfully, but these errors were encountered: