Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1552419065: Socket error on client NAME, disconnecting. #1197

Open
freekvh opened this issue Mar 12, 2019 · 4 comments
Open

1552419065: Socket error on client NAME, disconnecting. #1197

freekvh opened this issue Mar 12, 2019 · 4 comments

Comments

@freekvh
Copy link

freekvh commented Mar 12, 2019

I noticed some Issues with a similar topic yet I feel mine is a bit different. I use Mosquitto on hass.io, this is what my log looks like (on repeat):


1552419184: New connection from 192.168.1.3 on port 1883.
1552419184: |-- mosquitto_auth_unpwd_check(freek-mqtt)
1552419184: |-- ** checking backend http
1552419184: |-- url=https://127.0.0.1:8080/login
1552419184: |-- data=username=freek-mqtt&password=Sneek676&topic=&acc=-1&clientid=
[INFO] found freek-mqtt on local database
1552419186: |-- getuser(freek-mqtt) AUTHENTICATED=1 by http
1552419186: New client connected from 192.168.1.3 as slimme_meter (c1, k30, u'freek-mqtt').
1552419186: |-- mosquitto_auth_acl_check(..., client id not available, freek-mqtt, home/smart_meter/huidig_verbruik, MOSQ_ACL_WRITE)
1552419186: |-- aclcheck(freek-mqtt, home/smart_meter/huidig_verbruik, 2) CACHEDAUTH: 0
1552419186: |-- mosquitto_auth_acl_check(..., client id not available, freek-mqtt, home/smart_meter/energie_geleverd, MOSQ_ACL_WRITE)
1552419186: |-- aclcheck(freek-mqtt, home/smart_meter/energie_geleverd, 2) CACHEDAUTH: 0
1552419186: |-- mosquitto_auth_acl_check(..., client id not available, freek-mqtt, home/smart_meter/gasmeterstand, MOSQ_ACL_WRITE)
1552419186: |-- aclcheck(freek-mqtt, home/smart_meter/gasmeterstand, 2) CACHEDAUTH: 0
1552419186: Socket error on client slimme_meter, disconnecting.

This is the code I use to connect:

#!/usr/bin/python3
"""
A script to read the slimme meter and send out the results via mqtt.
"""

import serial
import sys
import paho.mqtt.client as mqtt

# Dictionary of the data we need
code2value = {'1-0:1.8.1'  : 'laag_tarief_meter_geleverd',
              '1-0:1.8.2'  : 'hoog_tarief_meter_geleverd',
              '1-0:1.7.0'  : 'huidig_verbruik',
              '0-1:24.2.1' : 'gasmeterstand'}

# Configure the parameters needed to read the port
ser = serial.Serial()
ser.baudrate = 115200
ser.port="/dev/ttyUSB0"

# Open the connection
ser.open()

# Initiate mqtt connection
broker_address="rpi2.hmrt.nl" # Set the mqtt broker address
client = mqtt.Client(client_id="slimme_meter") #create new instance
client.username_pw_set('freek-mqtt', password='Sneek676')
client.connect(broker_address, keepalive=30) #connect to broker

# Capture one full telegram, terminate at the first "!"
telegram = []
line = ''
while '!' not in line:
    line = ser.readline().decode('utf-8')
    telegram.append(line)

# Select only the values of interest, add to a new dictionary, we do this because
# we first want to combime hoog and laag tarief before publishing
quantity2value = dict()
for line in telegram:
    for code in code2value:
        if code in line:
            value    = float(line.split('(')[-1].split('*')[0])
            unit     = line.split('(')[-1].split('*')[-1].replace(')','')
            quantity = code2value[code]
            quantity2value[quantity] = value
# Compute the total "energie geleverd"
quantity2value['energie_geleverd'] = quantity2value['laag_tarief_meter_geleverd'] + quantity2value['hoog_tarief_meter_geleverd']

# Define the quantities of interest and publish using mqtt
quantities = ['huidig_verbruik', 'energie_geleverd', 'gasmeterstand']
for quantity in quantities:
    #print(quantity, round(quantity2value[quantity], 3))
    client.publish('home/smart_meter/'+quantity, round(quantity2value[quantity], 3)) #publish
    print(quantity, round(quantity2value[quantity], 3))

I don't understand the issues, I had mqtt working before without authentication but it suddenly stopped working so I went this way. Does anyone understand what happens?

@karlp
Copy link
Contributor

karlp commented Mar 20, 2019

so, you had it working without authentication and then that stopped? Or, I tried adding authentication and now it doens' twork? It presnetly just looks like you have an auth plugin that is refusing you. Whether that was you rgoal or not is beyond me, but it's a config "issue" with your use of that plugin.

@freekvh
Copy link
Author

freekvh commented Mar 22, 2019

Indeed, mqtt using Mosquitto has been very shacky for me, it worked a couple of times until hass.io updates. But I uninstalled Mosquitto and now use the hass.io build-in mqtt server of hass.io and it works well.

It could indeed be a config issue but then it is strange that it worked every now and then with the same config.

@sadamchandra
Copy link

the same issue was observed in my setup also i am using mosquitto-1.5.5
getting below log continuously,
Socket error on client disconnecting

@sadamchandra
Copy link

any update on the above issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants