(self, url, headers={}, auth=None, transports=None,
                      namespaces=None, socketio_path='socket.io', wait=True,
                      wait_timeout=1)
Connect to a Socket.IO server.

        :param url: The URL of the Socket.IO server. It can include custom
                    query string parameters if required by the server. If a
                    function is provided, the client will invoke it to obtain
                    the URL each time a connection or reconnection is
                    attempted.
        :param headers: A dictionary with custom headers to send with the
                        connection request. If a function is provided, the
                        client will invoke it to obtain the headers dictionary
                        each time a connection or reconnection is attempted.
        :param auth: Authentication data passed to the server with the
                     connection request, normally a dictionary with one or
                     more string key/value pairs. If a function is provided,
                     the client will invoke it to obtain the authentication
                     data each time a connection or reconnection is attempted.
        :param transports: The list of allowed transports. Valid transports
                           are ``'polling'`` and ``'websocket'``. If not
                           given, the polling transport is connected first,
                           then an upgrade to websocket is attempted.
        :param namespaces: The namespaces to connect as a string or list of
                           strings. If not given, the namespaces that have
                           registered event handlers are connected.
        :param socketio_path: The endpoint where the Socket.IO server is
                              installed. The default value is appropriate for
                              most cases.
        :param wait: if set to ``True`` (the default) the call only returns
                     when all the namespaces are connected. If set to
                     ``False``, the call returns as soon as the Engine.IO
                     transport is connected, and the namespaces will connect
                     in the background.
        :param wait_timeout: How long the client should wait for the
                             connection. The default is 1 second. This
                             argument is only considered when ``wait`` is set
                             to ``True``.

        Note: this method is a coroutine.

        Example usage::

            sio = socketio.AsyncClient()
            sio.connect('http://localhost:5000')
Connect to a Socket.IO server.
Connect to a Socket . IO server .
async def connect(self, url, headers={}, auth=None, transports=None,
                      namespaces=None, socketio_path='socket.io', wait=True,
                      wait_timeout=1):
        """Connect to a Socket.IO server.

        :param url: The URL of the Socket.IO server. It can include custom
                    query string parameters if required by the server. If a
                    function is provided, the client will invoke it to obtain
                    the URL each time a connection or reconnection is
                    attempted.
        :param headers: A dictionary with custom headers to send with the
                        connection request. If a function is provided, the
                        client will invoke it to obtain the headers dictionary
                        each time a connection or reconnection is attempted.
        :param auth: Authentication data passed to the server with the
                     connection request, normally a dictionary with one or
                     more string key/value pairs. If a function is provided,
                     the client will invoke it to obtain the authentication
                     data each time a connection or reconnection is attempted.
        :param transports: The list of allowed transports. Valid transports
                           are ``'polling'`` and ``'websocket'``. If not
                           given, the polling transport is connected first,
                           then an upgrade to websocket is attempted.
        :param namespaces: The namespaces to connect as a string or list of
                           strings. If not given, the namespaces that have
                           registered event handlers are connected.
        :param socketio_path: The endpoint where the Socket.IO server is
                              installed. The default value is appropriate for
                              most cases.
        :param wait: if set to ``True`` (the default) the call only returns
                     when all the namespaces are connected. If set to
                     ``False``, the call returns as soon as the Engine.IO
                     transport is connected, and the namespaces will connect
                     in the background.
        :param wait_timeout: How long the client should wait for the
                             connection. The default is 1 second. This
                             argument is only considered when ``wait`` is set
                             to ``True``.

        Note: this method is a coroutine.

        Example usage::

            sio = socketio.AsyncClient()
            sio.connect('http://localhost:5000')
        """
        if self.connected:
            raise exceptions.ConnectionError('Already connected')

        self.connection_url = url
        self.connection_headers = headers
        self.connection_auth = auth
        self.connection_transports = transports
        self.connection_namespaces = namespaces
        self.socketio_path = socketio_path

        if namespaces is None:
            namespaces = list(set(self.handlers.keys()).union(
                set(self.namespace_handlers.keys())))
            if len(namespaces) == 0:
                namespaces = ['/']
        elif isinstance(namespaces, str):
            namespaces = [namespaces]
        self.connection_namespaces = namespaces
        self.namespaces = {}
        if self._connect_event is None:
            self._connect_event = self.eio.create_event()
        else:
            self._connect_event.clear()
        real_url = await self._get_real_value(self.connection_url)
        real_headers = await self._get_real_value(self.connection_headers)
        try:
            await self.eio.connect(real_url, headers=real_headers,
                                   transports=transports,
                                   engineio_path=socketio_path)
        except engineio.exceptions.ConnectionError as exc:
            await self._trigger_event(
                'connect_error', '/',
                exc.args[1] if len(exc.args) > 1 else exc.args[0])
            raise exceptions.ConnectionError(exc.args[0]) from None

        if wait:
            try:
                while True:
                    await asyncio.wait_for(self._connect_event.wait(),
                                           wait_timeout)
                    self._connect_event.clear()
                    if set(self.namespaces) == set(self.connection_namespaces):
                        break
            except asyncio.TimeoutError:
                pass
            if set(self.namespaces) != set(self.connection_namespaces):
                await self.disconnect()
                raise exceptions.ConnectionError(
                    'One or more namespaces failed to connect')

        self.connected = True
async def connect ( self , url , headers = { } , auth = None , transports = None , namespaces = None , socketio_path = 'socket.io' , wait = True , wait_timeout = 1 ) : if self . connected : raise exceptions . ConnectionError ( 'Already connected' ) self . connection_url = url self . connection_headers = headers self . connection_auth = auth self . connection_transports = transports self . connection_namespaces = namespaces self . socketio_path = socketio_path if namespaces is None : namespaces = list ( set ( self . handlers . keys ( ) ) . union ( set ( self . namespace_handlers . keys ( ) ) ) ) if len ( namespaces ) == 0 : namespaces = [ '/' ] elif isinstance ( namespaces , str ) : namespaces = [ namespaces ] self . connection_namespaces = namespaces self . namespaces = { } if self . _connect_event is None : self . _connect_event = self . eio . create_event ( ) else : self . _connect_event . clear ( ) real_url = await self . _get_real_value ( self . connection_url ) real_headers = await self . _get_real_value ( self . connection_headers ) try : await self . eio . connect ( real_url , headers = real_headers , transports = transports , engineio_path = socketio_path ) except engineio . exceptions . ConnectionError as exc : await self . _trigger_event ( 'connect_error' , '/' , exc . args [ 1 ] if len ( exc . args ) > 1 else exc . args [ 0 ] ) raise exceptions . ConnectionError ( exc . args [ 0 ] ) from None if wait : try : while True : await asyncio . wait_for ( self . _connect_event . wait ( ) , wait_timeout ) self . _connect_event . clear ( ) if set ( self . namespaces ) == set ( self . connection_namespaces ) : break except asyncio . TimeoutError : pass if set ( self . namespaces ) != set ( self . connection_namespaces ) : await self . disconnect ( ) raise exceptions . ConnectionError ( 'One or more namespaces failed to connect' ) self . connected = True