Max retries exceeded with url:

Hey,
I have a problem where I few py scripts running and sending data to my influxdb database (to the main server) all send to the same database with different measurements. Where the interval is 5 seconds?
I think that’s why I’m receiving the “Exception occurred” when running the script, the script is working but every moment the error comes. Below i will paste the py script

$ influx --version
InfluxDB shell version: 1.8.10

py script;

GNU nano 5.4 door.py *

#!/usr/bin/env python3

import time

import glob

import os

os.system(‘modprobe w1-gpio’)

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

frontRoomSmallDoor = 22

backSmallDoor = 23

garageMainDoor = 24

repeatDelay = 5 # change to 30 as per requesting

GPIO.setup(coolRoomSmallDoor, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(freezerSmallDoor, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(freezerMainDoor, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

from influxdb import InfluxDBClient

client = InfluxDBClient(host=‘192.168.31.234’, port=8086, username=‘user’, password=‘password^’, database=‘database’)

#client.get_list_database()

client.switch_database(‘database’)

while True:

csd = 0

print("front Small Door: ", end = "")

if GPIO.input(coolRoomSmallDoor) > 0:

    print("Closed")

else:

    print("Opened")

    csd = 1

fsd = 0

print("back Small Door: ", end = "")

if GPIO.input(freezerSmallDoor) > 0:

    print("Closed")

else:

    print("Opened")

    fsd = 1

fmd = 0

print("garage Main Door: ", end = "")

if GPIO.input(freezerMainDoor) > 0:

    print("Closed")

else:

    print("Opened")

    fmd = 1

# TODO send data to influx

json_body = [

 {

    "measurement": "doors",

    "tags": {

        "Device": "door-senor",

        "ID": "se"

    },

    "fields": {

        "front_small": csd,

        "back_small": fsd,

       "garage_main": fmd,

     }

    }

]

try:

    client.write_points(json_body)

except Exception as e:

    print("Exception occured: ", e)

time.sleep(repeatDelay)

Exception occurred

the output;

front Small Door: Closed
back Small Door: Closed
garage Main Door: Closed
front Small Door: Closed
back Small Door: Closed
garage Main Door: Closed
Exception occured: HTTPConnectionPool(host=‘192.168.31.234’, port=8086): Max retries exceeded with url: /write?db=dtmtelegrafdata (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0xb5d434d8>: Failed to establish a new connection: [Errno 111] Connection refused’))
front Small Door: Closed
back Small Door: Closed
garage Main Door: Closed
Exception occured: HTTPConnectionPool(host=‘192.168.31.234’, port=8086): Max retries exceeded with url: /write?db=dtmtelegrafdata (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0xb5e06f88>: Failed to establish a new connection: [Errno 111] Connection refused’))
front Small Door: Closed
back Small Door: Closed
garage Main Door: Closed
Exception occured: HTTPConnectionPool(host=‘192.168.31.234’, port=8086): Max retries exceeded with url: /write?db=dtmtelegrafdata (Caused by NewConnectionError(‘<urllib3.connection.HTTPConnection object at 0xb5d434d8>: Failed to establish a new connection: [Errno 111] Connection refused’))
front Small Door: Closed
back Small Door: Closed
garage Main Door: Closed
front Small Door: Closed
back Small Door: Closed
garage Main Door: Closed