async def socket_connection(self):
if not self._registered:<EOL><INDENT>_LOGGER.error('<STR_LIT>')<EOL>return<EOL><DEDENT>url = '<STR_LIT>'.format(<EOL>self.construct_url(SOCKET_URL), self._api_id, self._api_key)<EOL>fail_count = <NUM_LIT:0><EOL>while True:<EOL><INDENT>_LOGGER.debug('<STR_LIT>')<EOL>try:<EOL><INDENT>with async_timeout.timeout(DEFAULT_TIMEOUT,<EOL>loop=self._event_loop):<EOL><INDENT>self.wsck = await self._api_session.ws_connect(url)<EOL><DEDENT>try:<EOL><INDENT>msg = await self.wsck.send_str(<EOL>'<STR_LIT>')<EOL><DEDENT>except Exception as err:<EOL><INDENT>_LOGGER.error('<STR_LIT>', err)<EOL>raise ValueError('<STR_LIT>')<EOL><DEDENT>_LOGGER.debug('<STR_LIT>')<EOL>fail_count = <NUM_LIT:0><EOL>while True:<EOL><INDENT>msg = await self.wsck.receive()<EOL>if msg.type == aiohttp.WSMsgType.text:<EOL><INDENT>self.process_msg(msg.data)<EOL><DEDENT>elif msg.type == aiohttp.WSMsgType.closed:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>elif msg.type == aiohttp.WSMsgType.error:<EOL><INDENT>_LOGGER.debug(<EOL>'<STR_LIT>', msg)<EOL>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>except (aiohttp.ClientError, asyncio.TimeoutError,<EOL>aiohttp.WSServerHandshakeError,<EOL>ConnectionRefusedError, OSError, ValueError) as err:<EOL><INDENT>if not self._shutdown:<EOL><INDENT>fail_count += <NUM_LIT:1><EOL>_LOGGER.debug('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>(fail_count * <NUM_LIT:5>) + <NUM_LIT:5>, err)<EOL>await asyncio.sleep(<NUM_LIT:15>, self._event_loop)<EOL>continue<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>
Open websocket connection.