guard against exceptions in connect(), which can happen due to e.g. security violations for websockets