fix bug of connecting with timeout