Fix run_query connection timeout issues.

Solves run_query timeout issues by creating a new connection if the last one times out.