adding time.sleep(0.001) before connection close