{"action":"created","issue":{"url":"https://api.github.com/repos/Crypto-toolbox/btfxwss/issues/130","repository_url":"https://api.github.com/repos/Crypto-toolbox/btfxwss","labels_url":"https://api.github.com/repos/Crypto-toolbox/btfxwss/issues/130/labels{/name}","comments_url":"https://api.github.com/repos/Crypto-toolbox/btfxwss/issues/130/comments","events_url":"https://api.github.com/repos/Crypto-toolbox/btfxwss/issues/130/events","html_url":"https://github.com/Crypto-toolbox/btfxwss/issues/130","id":313827819,"number":130,"title":"Reconnecting client","user":{"login":"pegazik80","id":10697099,"avatar_url":"https://avatars3.githubusercontent.com/u/10697099?v=4","gravatar_id":"","url":"https://api.github.com/users/pegazik80","html_url":"https://github.com/pegazik80","followers_url":"https://api.github.com/users/pegazik80/followers","following_url":"https://api.github.com/users/pegazik80/following{/other_user}","gists_url":"https://api.github.com/users/pegazik80/gists{/gist_id}","starred_url":"https://api.github.com/users/pegazik80/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pegazik80/subscriptions","organizations_url":"https://api.github.com/users/pegazik80/orgs","repos_url":"https://api.github.com/users/pegazik80/repos","events_url":"https://api.github.com/users/pegazik80/events{/privacy}","received_events_url":"https://api.github.com/users/pegazik80/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-12T17:53:47Z","updated_at":"2018-04-13T21:15:59Z","closed_at":"2018-04-13T21:15:59Z","author_association":"NONE","body":"I am not sure whether other people see the same issue but from time to time my client becomes stale and data stops arriving.\r\nI have tried two approaches to deal with this problem in the main loop:\r\nApproach A) - eventually resulted in an error \"too many open files\", unfortunately the log that contained exact exception has been deleted.\r\n```python\r\n        if self.wss_client is None or self.wss_client.conn.connected.is_set():\r\n            if self.WSS_CLIENT_VERSION == 1:\r\n                self.wss_client = BtfxWss(url=\"wss://api.bitfinex.com/ws\")  # v1\r\n            else:\r\n                self.wss_client = BtfxWss()  # v2\r\n\r\n            self.wss_client.start()\r\n            while not self.wss_client.conn.connected.is_set():\r\n                time.sleep(1)\r\n            self.logger.info(\"wss client connected\")\r\n```\r\nApproach B) - There is no exception but after disconnection I end up in neverending loop printing ever second reset(): \"Waiting for connection to be set up..\" and not being able to pick it up again.\r\n```python\r\n        if self.wss_client is None:\r\n            if self.WSS_CLIENT_VERSION == 1:\r\n                self.wss_client = BtfxWss(url=\"wss://api.bitfinex.com/ws\")  # v1\r\n            else:\r\n                self.wss_client = BtfxWss()  # v2\r\n\r\n            self.wss_client.start()\r\n            while not self.wss_client.conn.connected.is_set():\r\n                time.sleep(1)\r\n            self.logger.info(\"wss client connected\")\r\n\r\n        if not self.wss_client.conn.connected.is_set():\r\n            self.wss_client.reset()\r\n            self.logger.info(\"wss client re-connected\")\r\n```\r\nWhat is the correct way of dealing with client reconnect events?\r\n\r\nThanks for great work by the way :)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Crypto-toolbox/btfxwss/issues/comments/381262580","html_url":"https://github.com/Crypto-toolbox/btfxwss/issues/130#issuecomment-381262580","issue_url":"https://api.github.com/repos/Crypto-toolbox/btfxwss/issues/130","id":381262580,"user":{"login":"pegazik80","id":10697099,"avatar_url":"https://avatars3.githubusercontent.com/u/10697099?v=4","gravatar_id":"","url":"https://api.github.com/users/pegazik80","html_url":"https://github.com/pegazik80","followers_url":"https://api.github.com/users/pegazik80/followers","following_url":"https://api.github.com/users/pegazik80/following{/other_user}","gists_url":"https://api.github.com/users/pegazik80/gists{/gist_id}","starred_url":"https://api.github.com/users/pegazik80/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pegazik80/subscriptions","organizations_url":"https://api.github.com/users/pegazik80/orgs","repos_url":"https://api.github.com/users/pegazik80/repos","events_url":"https://api.github.com/users/pegazik80/events{/privacy}","received_events_url":"https://api.github.com/users/pegazik80/received_events","type":"User","site_admin":false},"created_at":"2018-04-13T21:15:59Z","updated_at":"2018-04-13T21:15:59Z","author_association":"NONE","body":"I am sorry, the problem I reported was actually originating somewhere else. The code Approach A) is working well, I already saw few cases of spontaneous dis- and re-connections using this code."}}
{"actor":{"display_login":"pegazik80"}}