Page 1 of 1

MQTT ERROR: {MQTT Client ID}{IP address}PUBLISH HomeAutomation∕feeds∕rel rejected, only shared feeds may be publi

Posted: Wed Oct 30, 2019 1:28 pm
by mun
Hello Guys,
I am doing a Home Automation project which esp32 board as a Publisher and also a Subscriber, the broker is the Adafruit.io.

Code: Select all

from MQTT2 import MQTTClient
from machine import Pin
import machine 
import time
import Main2
from machine import UART
import os
uart = UART(2, 115200)
os.dupterm(uart)
def settimeout(duration): 
    pass
def sub_cb(topic, msg): 
   print(msg) 
wlan = Main2.get_connection()
if wlan is None:
    print("Could not initialize the network connection.")
pass
client = MQTTClient("oktehn", "io.adafruit.com",user="HomeAutomation", password=
                    "{key_io_provided_by_adafruit_io}", port=1883)
client.settimeout = settimeout
client.connect()

while True:
        print("Sending ON") 
        client.publish(topic="HomeAutomation∕feeds∕relay-1", msg="ON")
        time.sleep(1) 
        print("Sending OFF") 
       [b] client.publish(topic="HomeAutomation∕feeds∕relay-1", msg="OFF")[/b]
        time.sleep(1)
Result/Shell:
Sending ON
Sending OFF
Sending ON
Sending OFF
Traceback (most recent call last):
File "<stdin>", line 34, in <module>
File "MQTT2.py", line 126, in publish
OSError: [Errno 104] ECONNRESET

-Notification in the Adafruit.io:
Had shown in the title.

*Noted
1) line 34 code is highlighted inside the code part.
2) line 126 in MQTT2 is this code: self.sock.write(pkt, i + 1) for more detail please see the link at below.
MQTT2 library link: https://github.com/pycom/pycom-librarie ... tt/mqtt.py
Bundle code of MQTT library link: https://github.com/pycom/pycom-librarie ... mples/mqtt
3) Main2 is for connecting the WIFI by using Webserver.

Explanation of the code:
1) This code is using UART2 with 115200 baud rate. This is because I saw the link of bundle code of MQTT library link is using UART0 with 115200 but for my esp32, its result is an error because UART0 is dedicated to REPL, so I use UART2.
2) for the if loop, it is for the checking the esp32 board is connected to the WIFI or not.
3) The info for the MQTT client.
4) The infinite loop of publishing Yes/No to relay-1 which a feed in the dashboard of the Adafruit.io.

Question:
1) Do I need an Adafruit.io account for the esp32 board to solve this error? if yes, then how do I get the library of that.
2) Another reason to cause the error occurs?

Thanks in advance.

Re: MQTT ERROR: {MQTT Client ID}{IP address}PUBLISH HomeAutomation∕feeds∕rel rejected, only shared feeds may be publi

Posted: Fri Nov 01, 2019 11:10 am
by pythoncoder
Where did you get the MQTT2 library? It isn't in the official micropython-lib. If it's an Adafruit library you might get a better response in their forum. Otherwise contact the author of the library.