handling reconnection to database every 500 ms