code: async def socket_connection(self):
          
          if not self._registered:
              _LOGGER.error('Client not registered, cannot start socket.')
              return
  
          url = '{}?DeviceID={}&api_key={}'.format(
              self.construct_url(SOCKET_URL), self._api_id, self._api_key)
  
          fail_count = 0
          while True:
              _LOGGER.debug('Attempting Socket Connection.')
              try:
                  with async_timeout.timeout(DEFAULT_TIMEOUT,
                                             loop=self._event_loop):
                      self.wsck = await self._api_session.ws_connect(url)
  
                  # Enable sever session updates:
                  try:
                      msg = await self.wsck.send_str(
                          '{"MessageType":"SessionsStart", "Data": "0,1500"}')
                  except Exception as err:
                      # Catch all for now
                      _LOGGER.error('Failure setting session updates: %s', err)
                      raise ValueError('Session updates error.')
  
                  _LOGGER.debug('Socket Connected!')
                  fail_count = 0
                  while True:
                      msg = await self.wsck.receive()
                      if msg.type == aiohttp.WSMsgType.text:
                          # Process data
                          self.process_msg(msg.data)
  
                      elif msg.type == aiohttp.WSMsgType.closed:
                          raise ValueError('Websocket was closed.')
                      elif msg.type == aiohttp.WSMsgType.error:
                          _LOGGER.debug(
                              'Websocket encountered an error: %s', msg)
                          raise ValueError('Websocket error.')
  
              except (aiohttp.ClientError, asyncio.TimeoutError,
                      aiohttp.WSServerHandshakeError,
                      ConnectionRefusedError, OSError, ValueError) as err:
                  if not self._shutdown:
                      fail_count += 1
                      _LOGGER.debug('Websocket unintentionally closed.'
                                    ' Trying reconnect in %ss. Error: %s',
                                    (fail_count * 5) + 5, err)
                      await asyncio.sleep(15, self._event_loop)
                      continue
                  else:
                      break
docs: Open websocket connection.