help?Connecting to MQTT... You have been banned from connecting. Please contact the MQTT server administrator for more details.
MQTT Ban
Moderators: adafruit_support_bill, adafruit
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- noelportugal
- Posts: 8
- Joined: Wed Nov 11, 2009 1:08 am
MQTT Ban
First I started using the AdafruitIO Arduino library, and was getting "Network disconnected" almos immediately after connecting...Then I change to MQTT lib and now getting this:
- hansoloqwertzui
- Posts: 4
- Joined: Sat Feb 24, 2018 8:43 am
Re: MQTT Ban
I have the same issue for some days now. Couldn't find an answer either. I don't exceed any limitations of my plan.
- hansoloqwertzui
- Posts: 4
- Joined: Sat Feb 24, 2018 8:43 am
Re: MQTT Ban
Still have this problem, any suggestions?
- adafruit_support_carter
- Posts: 29483
- Joined: Tue Nov 29, 2016 2:45 pm
Re: MQTT Ban
Post the complete code for the sketch your are using that causes this.
- hansoloqwertzui
- Posts: 4
- Joined: Sat Feb 24, 2018 8:43 am
Re: MQTT Ban
Here my code. The thread basically publishs every 15 seconds a data point to the feeds "temperature", "humidity", "light", "water", "water_1", "water_2".
Code: Select all
import serial
import time
from threading import Thread
import logging
from Adafruit_IO import *
import datetime
import numpy as np
class MyThread(Thread):
def __init__(self, val, client):
''' Constructor. '''
Thread.__init__(self)
self.val = val
self.client = client
self.values = ["temperature", "humidity", "light",
"water", "water_1", "water_2"] # add light test feed
self.running = True
self.my_dict = {}
def run(self):
while self.running:
try:
self.client.loop(5)
if not self.client.is_connected():
self.client.connect()
for tmp in self.values:
if tmp in self.my_dict:
y = self.my_dict[tmp]
y = float(y)
print(tmp + ": " + str(y))
self.client.publish(tmp, y)
time.sleep(self.val)
except Exception as e:
x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
logging.debug("MyThread: " + x + ":" + str(e))
def set_run(self, running):
self.running = running
def set_dict_value(self, key, value):
if key in self.values:
self.my_dict[key] = value
# Define callback functions which will be called when certain events happen.
def connected(client):
x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
# Connected function will be called when the client is connected to Adafruit IO.
#logging.debug(x + ': Connected to Adafruit IO!')
def disconnected(client):
x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
# Disconnected function will be called when the client disconnects.
#logging.debug(x + ': Disconnected from Adafruit IO!')
logging.basicConfig(filename='/home/pi/plant_monitor.log', level=logging.DEBUG)
values = ["temperature", "humidity", "light", "water", "water_1", "water_2"]
client = MQTTClient('BANNED', 'BANNED')
client.on_connect = connected
client.on_disconnect = disconnected
client.connect()
#client.loop_background()
myThread = MyThread(15, client)
lightOn = True
line = ""
runLoop = True
# serial connection
ser = None
temps = [0 for x in range(60)]
# connect serial arduino
try:
ser = serial.Serial('/dev/ttyACM0', 9600)
myThread.start()
except Exception as e:
x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
logging.debug(x + ":" + "Serial connection broken!" + str(e))
runLoop = False
k = 0
meanTemp = 0.0
turnedOn = False
while runLoop:
try:
if ser.is_open:
line = ser.readline().decode().strip('\r').strip('\n').strip()
else:
ser = serial.Serial('/dev/ttyACM0', 9600)
except Exception as e:
x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
logging.debug(x + ":" + "Serial connection broken!" + str(e))
myThread.set_run(False)
break
try:
key = line[:line.find("=")]
# check if key in values
if key in values:
# substring value
value = line[line.find("=")+1:]
if len(value) < 7:
myThread.set_dict_value(key, value)
if key == values[0]:
if k < 60:
temps[k] = float(value)
k += 1
#smooth signal
myThread.set_dict_value(key, np.median(temps))
if k == 60:
medianTemp = np.median(temps)
myThread.set_dict_value(key, medianTemp)
k = 0
now = datetime.datetime.now()
is_night = now.hour >= 18 or now.hour <= 6
if medianTemp < 22.0 and not turnedOn and not is_night:
ser.write('1'.encode())
turnedOn = True
if medianTemp < 19.0 and not turnedOn and is_night:
ser.write('1'.encode())
turnedOn = True
if medianTemp >= 22.0 and not is_night:
ser.write('0'.encode())
if medianTemp >= 19.0 and is_night:
ser.write('0'.encode())
if medianTemp <= 18.0:
turnedOn = False
time.sleep(1)
except Exception as e:
x = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
logging.debug("Dict and Temperature Exception: " + x + ":" + str(e))
- abachman
- Posts: 352
- Joined: Mon Feb 01, 2010 12:48 pm
Re: MQTT Ban
Hi all,
There are two different bans happening here.
noelportugal, we added your account to a permanent MQTT ban list about 2 years ago, it looks like. Your account was hitting the MQTT server attempting authentication a few times per second, 24 hours a day. Enough that it was hard to tell the difference between an intentional and unintentional denial-of-service attack :( We've updated our throttling / temporary-ban logic and changed the way the MQTT broker handles invalid subscription topics (which may have been the cause) so that a runaway script or device won't be as likely or as dramatic. I've cleared the permanent ban so you should be able to reconnect to the MQTT service now.
hansoloqwertzui, if I'm reading this correctly, you're publishing 6 data points 4 times per minute which, if you're on the free plan, should always be permitted. Are you running any other clients or anything subscribing to IO? Our previous method of handling invalid subscription topics on the MQTT broker was to disconnect the client on invalid or unauthorized subscriptions, which lead in some cases to the runaway authentication problem if clients didn't pause between reconnection attempts. Unfortunately, if one client attempts to authenticate on your account too many times (20 attempts per minute) it will temporarily ban you from re-authenticating. We deployed a change last Friday that changed that behavior over to dropping the subscription request and publishing an error message to your {username}/errors topic. It's not clear if that's your issue, however.
In the meantime, I reset your rate limits to see if that helps with your problem. That would only fix the issue if you've exceeded the limit and haven't stopped attempting to publish or sign in for more than a minute. After 60 seconds all the rate-limiting will automatically clear on its own.
- adam b.
There are two different bans happening here.
noelportugal, we added your account to a permanent MQTT ban list about 2 years ago, it looks like. Your account was hitting the MQTT server attempting authentication a few times per second, 24 hours a day. Enough that it was hard to tell the difference between an intentional and unintentional denial-of-service attack :( We've updated our throttling / temporary-ban logic and changed the way the MQTT broker handles invalid subscription topics (which may have been the cause) so that a runaway script or device won't be as likely or as dramatic. I've cleared the permanent ban so you should be able to reconnect to the MQTT service now.
hansoloqwertzui, if I'm reading this correctly, you're publishing 6 data points 4 times per minute which, if you're on the free plan, should always be permitted. Are you running any other clients or anything subscribing to IO? Our previous method of handling invalid subscription topics on the MQTT broker was to disconnect the client on invalid or unauthorized subscriptions, which lead in some cases to the runaway authentication problem if clients didn't pause between reconnection attempts. Unfortunately, if one client attempts to authenticate on your account too many times (20 attempts per minute) it will temporarily ban you from re-authenticating. We deployed a change last Friday that changed that behavior over to dropping the subscription request and publishing an error message to your {username}/errors topic. It's not clear if that's your issue, however.
In the meantime, I reset your rate limits to see if that helps with your problem. That would only fix the issue if you've exceeded the limit and haven't stopped attempting to publish or sign in for more than a minute. After 60 seconds all the rate-limiting will automatically clear on its own.
- adam b.
- hansoloqwertzui
- Posts: 4
- Joined: Sat Feb 24, 2018 8:43 am
Re: MQTT Ban
Thanks for the detailed reply! Yes, I'm sending 24 data points per minute. I am not running any other clients or subscriptions, only this script.
I still have this problem. After some time the connection drops and when trying to reconnect I get the following error message: "Error connecting to Adafruit IO with rc: 7".
As stated in my script I'm trying to reconnect every 15 seconds after the connection drops.
I still have this problem. After some time the connection drops and when trying to reconnect I get the following error message: "Error connecting to Adafruit IO with rc: 7".
As stated in my script I'm trying to reconnect every 15 seconds after the connection drops.
- homemonitoringsystem
- Posts: 1
- Joined: Mon Apr 23, 2018 3:01 pm
Re: MQTT Ban
i have the same problem, saying that "you have been banned from connecting. Please contact the MQTT server administrator for more details".
- joaco_123
- Posts: 1
- Joined: Mon Jun 18, 2018 8:57 pm
Re: MQTT Ban
I have been banned, saying that "you have been banned from connecting. Please contact the MQTT server administrator for more details".
please help me!
please help me!
- Antonzlo
- Posts: 4
- Joined: Fri Sep 06, 2019 11:31 am
Re: MQTT Ban
I have been banned in mqtt because I forgot to put delay while testing :(
- abachman
- Posts: 352
- Joined: Mon Feb 01, 2010 12:48 pm
Re: MQTT Ban
Hi Antonzlo,
Yep. Looks like we disabled your MQTT access in July.
Have you fixed the misbehaving client?
- adam b.
Yep. Looks like we disabled your MQTT access in July.
Have you fixed the misbehaving client?
- adam b.
- Antonzlo
- Posts: 4
- Joined: Fri Sep 06, 2019 11:31 am
Re: MQTT Ban
Yep, but it is strange, i started testing mqtt stuff only yesterday
- Antonzlo
- Posts: 4
- Joined: Fri Sep 06, 2019 11:31 am
Re: MQTT Ban
Hello, is there any updates? I want to start assembly tomorrow, but with ban it is impossible.
-Antonzlo
-Antonzlo
- abachman
- Posts: 352
- Joined: Mon Feb 01, 2010 12:48 pm
Re: MQTT Ban
We re-opened the MQTT server for your account last week but there are still a flood of publish messages from your account directed at the MQTT topic sonoff/tele/LWT, so something running with your account credentials is keeping you banned. Those messages in particular were why we added the account to the banlist.
You'll have to clean that up before new devices can access the service.
- adam b.
You'll have to clean that up before new devices can access the service.
- adam b.
- Antonzlo
- Posts: 4
- Joined: Fri Sep 06, 2019 11:31 am
Re: MQTT Ban
Hello, may be that is my light esp8266, I disabled it for now, is there any flood now?
-Antonzlo
-Antonzlo
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.