Virtual write sudenly not working

Hi. The code below used to work but after the reinstall of rasbian suddenly it gives the error on virtual write. Any suggestions. Using Blynk 1.0

Thank you

Full code

import RPi.GPIO as GPIO
import time
import blynklib
 
 
BLYNK_AUTH = 'xxx'
blynk = blynklib.Blynk(BLYNK_AUTH) 
 
#GPIO Mode (BOARD / BCM)
GPIO.setmode(GPIO.BCM)
 
#set GPIO Pins
GPIO_TRIGGER = 2
GPIO_ECHO = 3
 
#set GPIO direction (IN / OUT)
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)
 
def distance():
    # set Trigger to HIGH
    GPIO.output(GPIO_TRIGGER, True)
 
    # set Trigger after 0.01ms to LOW
    time.sleep(0.00001)
    GPIO.output(GPIO_TRIGGER, False)
 
    StartTime = time.time()
    StopTime = time.time()
 
    # save StartTime
    while GPIO.input(GPIO_ECHO) == 0:
        StartTime = time.time()
 
    # save time of arrival
    while GPIO.input(GPIO_ECHO) == 1:
        StopTime = time.time()
 
    # time difference between start and arrival
    TimeElapsed = StopTime - StartTime
    # multiply with the sonic speed (34300 cm/s)
    # and divide by 2, because there and back
    distance = (TimeElapsed * 34700) / 2
 
    return distance
 
if __name__ == '__main__':
    try:
        while True:
            dist = distance()
            print ("Measured Distance = %.1f cm" % dist)
            time.sleep(1)
            blynk.virtual_write(0, '{}'.format(dist))
 
        # Reset by pressing CTRL + C
    except KeyboardInterrupt:
        print("Measurement stopped by User")
        GPIO.cleanup()


Error:

Measured Distance = 172.4 cm
Traceback (most recent call last):
  File "visina_rezervar_blynk.py", line 54, in <module>
    blynk.virtual_write(0, '{}'.format(dist))
  File "/usr/local/lib/python3.7/dist-packages/blynklib.py", line 303, in virtual_write
    return self.send(self.virtual_write_msg(v_pin, *val))
  File "/usr/local/lib/python3.7/dist-packages/blynklib.py", line 165, in send
    return self._socket.send(data)
AttributeError: 'NoneType' object has no attribute 'send'