btfxwss/connection.py
def _connect(self):
        """Creates a websocket connection.

        :return:
        """
        self.log.debug("_connect(): Initializing Connection..")
        self.socket = websocket.WebSocketApp(
            self.url,
            on_open=self._on_open,
            on_message=self._on_message,
            on_error=self._on_error,
            on_close=self._on_close
        )

        if 'ca_certs' not in self.sslopt.keys():
            ssl_defaults = ssl.get_default_verify_paths()
            self.sslopt['ca_certs'] = ssl_defaults.cafile

        self.log.debug("_connect(): Starting Connection..")
        self.socket.run_forever(sslopt=self.sslopt,
                        http_proxy_host=self.http_proxy_host,
                        http_proxy_port=self.http_proxy_port,
                        http_proxy_auth=self.http_proxy_auth,
                        http_no_proxy=self.http_no_proxy)

        # stop outstanding ping/pong timers
        self._stop_timers()
        while self.reconnect_required.is_set():
            if not self.disconnect_called.is_set():
                self.log.info("Attempting to connect again in %s seconds."
                              % self.reconnect_interval)
                self.state = "unavailable"
                time.sleep(self.reconnect_interval)

                # We need to set this flag since closing the socket will
                # set it to False
                self.socket.keep_running = True
                self.socket.sock = None
                self.socket.run_forever(sslopt=self.sslopt,
                                http_proxy_host=self.http_proxy_host,
                                http_proxy_port=self.http_proxy_port,
                                http_proxy_auth=self.http_proxy_auth,
                                http_no_proxy=self.http_no_proxy)
            else:
                break
def _connect(self):
        self.log.debug("_connect(): Initializing Connection..")
        self.socket = websocket.WebSocketApp(
            self.url,
            on_open=self._on_open,
            on_message=self._on_message,
            on_error=self._on_error,
            on_close=self._on_close
        )

        if 'ca_certs' not in self.sslopt.keys():
            ssl_defaults = ssl.get_default_verify_paths()
            self.sslopt['ca_certs'] = ssl_defaults.cafile

        self.log.debug("_connect(): Starting Connection..")
        self.socket.run_forever(sslopt=self.sslopt,
                        http_proxy_host=self.http_proxy_host,
                        http_proxy_port=self.http_proxy_port,
                        http_proxy_auth=self.http_proxy_auth,
                        http_no_proxy=self.http_no_proxy)

        # stop outstanding ping/pong timers
        self._stop_timers()
        while self.reconnect_required.is_set():
            if not self.disconnect_called.is_set():
                self.log.info("Attempting to connect again in %s seconds."
                              % self.reconnect_interval)
                self.state = "unavailable"
                time.sleep(self.reconnect_interval)

                # We need to set this flag since closing the socket will
                # set it to False
                self.socket.keep_running = True
                self.socket.sock = None
                self.socket.run_forever(sslopt=self.sslopt,
                                http_proxy_host=self.http_proxy_host,
                                http_proxy_port=self.http_proxy_port,
                                http_proxy_auth=self.http_proxy_auth,
                                http_no_proxy=self.http_no_proxy)
            else:
                break
def _connect ( self ) : self . log . debug ( "_connect(): Initializing Connection.." ) self . socket = websocket . WebSocketApp ( self . url , on_open = self . _on_open , on_message = self . _on_message , on_error = self . _on_error , on_close = self . _on_close ) if 'ca_certs' not in self . sslopt . keys ( ) : ssl_defaults = ssl . get_default_verify_paths ( ) self . sslopt [ 'ca_certs' ] = ssl_defaults . cafile self . log . debug ( "_connect(): Starting Connection.." ) self . socket . run_forever ( sslopt = self . sslopt , http_proxy_host = self . http_proxy_host , http_proxy_port = self . http_proxy_port , http_proxy_auth = self . http_proxy_auth , http_no_proxy = self . http_no_proxy ) # stop outstanding ping/pong timers self . _stop_timers ( ) while self . reconnect_required . is_set ( ) : if not self . disconnect_called . is_set ( ) : self . log . info ( "Attempting to connect again in %s seconds." % self . reconnect_interval ) self . state = "unavailable" time . sleep ( self . reconnect_interval ) # We need to set this flag since closing the socket will # set it to False self . socket . keep_running = True self . socket . sock = None self . socket . run_forever ( sslopt = self . sslopt , http_proxy_host = self . http_proxy_host , http_proxy_port = self . http_proxy_port , http_proxy_auth = self . http_proxy_auth , http_no_proxy = self . http_no_proxy ) else : break
Creates a websocket connection.

        :return:
Creates a websocket connection .