slazarov / python-bittrex-websocket

Python websocket for Bittrex (non async).
http://python-bittrex-websocket-docs.readthedocs.io/en/latest/index.html
MIT License
103 stars 38 forks source link

Error at running in a docker container #53

Closed DrMartiner closed 6 years ago

DrMartiner commented 6 years ago

I have simple code to watch ticker & order book:

from time import sleep
from datetime import datetime

from bittrex_websocket.websocket_client import BittrexSocket

class MySocket(BittrexSocket):
    def on_orderbook(self, msg):
        print(f'on_orderbook at {self.now}')

    def on_orderbook_update(self, msg):
        print(f'on_orderbook_update at {self.now}')

    def on_ticker_update(self, msg):
        print(f'on_ticker_update at {self.now}')

    @property
    def now(self):
        return datetime.now().strftime('%M:%S')

if __name__ == "__main__":
    ws = MySocket()
    ws.enable_log()

    ws.subscribe_to_orderbook(['USDT-ETH'], 30)
    ws.subscribe_to_ticker_update(['USDT-ETH'])

    while True:
        try:
            sleep(1)
        except KeyboardInterrupt:
            ws.disconnect()

I try to running it at docker (Python 3.6.0):

version: '2'
services:
  collector:
    build: './back/.'
    restart: 'always'
    command: 'python bittrex-collector.py'
    working_dir: '/app/'
    volumes:
      - './back:/app'

I have the errors when (docker-compose up):

Creating trusttrade_redis_1     ... done
Creating trusttrade_redis_1     ...
Creating trusttrade_collector_1 ... done
Attaching to trusttrade_collector_1
collector_1  | 2018-03-20 13:30:15 - bittrex_websocket.websocket_client - INFO - [Connection][22980b5d6c4b42e8863abc6029fea332]:Trying to establish connection to Bittrex through https://socket-stage.bittrex.com/signalr.
collector_1  | 2018-03-20 13:30:20 - bittrex_websocket.websocket_client - ERROR - [Connection][22980b5d6c4b42e8863abc6029fea332]:Timeout for url https://socket-stage.bittrex.com/signalr. Please check your internet connection is on.
collector_1  | 2018-03-20 13:30:20 - bittrex_websocket.websocket_client - INFO - [Connection][22980b5d6c4b42e8863abc6029fea332]:Trying to establish connection to Bittrex through https://socket.bittrex.com/signalr.
collector_1  | 2018-03-20 13:30:25 - bittrex_websocket.websocket_client - ERROR - [Connection][22980b5d6c4b42e8863abc6029fea332]:Timeout for url https://socket.bittrex.com/signalr. Please check your internet connection is on.
collector_1  | 2018-03-20 13:30:25 - bittrex_websocket.websocket_client - ERROR - [Connection][22980b5d6c4b42e8863abc6029fea332]:Failed to establish connection through supplied URLS. Leaving to watchdog...
collector_1  | 2018-03-20 13:30:35 - bittrex_websocket.websocket_client - ERROR - Failed to subscribe [OrderBook][['USDT-ETH']] from connection 22980b5d6c4b42e8863abc6029fea332 after 20 seconds. The connection is probably down.
slazarov commented 6 years ago

Most likely nodejs is missing in your dockerfile.

DrMartiner commented 6 years ago

@slazarov what should I do to fix it?

DrMartiner commented 6 years ago

@slazarov what is node version I need?

slazarov commented 6 years ago

Hi, check the docker folder in the repo use it as a starting point. Latest version is fine.

DrMartiner commented 6 years ago

Grate! Thanks a lot!

slazarov commented 6 years ago

You are welcome :).