core: Use a connect timeout when opening websockets. Fixes #569