shirosaidev / stocksight

Stock market analyzer and predictor using Elasticsearch, Twitter, News headlines and Python natural language processing and sentiment analysis
https://shirosaidev.github.io/stocksight/
Apache License 2.0
2.12k stars 463 forks source link

ConnectionRefusedError with readme's examples #23

Closed r3v1 closed 4 years ago

r3v1 commented 4 years ago

Hi, I was trying to build the project and after configuring it as suggested in "How to use" section and running the first example with

python sentiment.py -s TSLA -k "Elon Musk,Musk,Tesla,SpaceX" --debug

I receive the next error log

2020-06-09 00:24:18,768 [INFO][stocksight] Creating new Elasticsearch index or using existing stocksight
2020-06-09 00:24:18,775 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.007s]
Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/connection/http_urllib3.py", line 115, in perform_request
    response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa6386eb710>: Failed to establish a new connection: [Errno 111] Connection refused
2020-06-09 00:24:18,776 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
2020-06-09 00:24:18,783 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.006s]

       _                     _                 
     _| |_ _           _   _| |_ _     _   _   
    |   __| |_ ___ ___| |_|   __|_|___| |_| |_ 
    |__   |  _| . |  _| '_|__   | | . |   |  _|
    |_   _|_| |___|___|_,_|_   _|_|_  |_|_|_|  
      |_|                   |_|   |___|                
          :) = +$   :( = -$    v0.1-b.11
    GitHub repo https://github.com/shirosaidev/stocksight
    StockSight website https://stocksight.diskoverspace.com

Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/connection/http_urllib3.py", line 115, in perform_request
    response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa6386eba50>: Failed to establish a new connection: [Errno 111] Connection refused
2020-06-09 00:24:18,783 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
2020-06-09 00:24:18,790 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.007s]
Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/connection/http_urllib3.py", line 115, in perform_request
    response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa638640cd0>: Failed to establish a new connection: [Errno 111] Connection refused
2020-06-09 00:24:18,790 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
2020-06-09 00:24:18,800 [WARNING][elasticsearch] PUT http://localhost:9200/stocksight [status:N/A request:0.009s]
Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/connection/http_urllib3.py", line 115, in perform_request
    response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa638640f90>: Failed to establish a new connection: [Errno 111] Connection refused
2020-06-09 00:24:18,800 [DEBUG][elasticsearch] > {"mappings": {"tweet": {"properties": {"author": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "language": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "friends": {"type": "long"}, "followers": {"type": "long"}, "statuses": {"type": "long"}, "date": {"type": "date"}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "tweet_id": {"type": "long"}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}, "newsheadline": {"properties": {"date": {"type": "date"}, "location": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}, "message": {"type": "string", "fields": {"english": {"type": "string", "analyzer": "english"}, "keyword": {"type": "keyword"}}}, "polarity": {"type": "float"}, "subjectivity": {"type": "float"}, "sentiment": {"type": "string", "fields": {"keyword": {"type": "keyword"}}}}}}}
Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/connection/http_urllib3.py", line 115, in perform_request
    response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, **kw)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/urllib3/connection.py", line 172, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fa638640f90>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/david/git/stocksight/sentiment.py", line 871, in <module>
    es.indices.create(index=args.index, body=mappings, ignore=[400, 404])
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/client/utils.py", line 73, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/client/indices.py", line 107, in create
    params=params, body=body)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/transport.py", line 312, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/home/david/git/stocksight/venv/lib/python3.7/site-packages/elasticsearch5/connection/http_urllib3.py", line 124, in perform_request
    raise ConnectionError('N/A', str(e), e)
elasticsearch5.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7fa638640f90>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7fa638640f90>: Failed to establish a new connection: [Errno 111] Connection refused)

Do I forgot something?

Thanks in advanced

shirosaidev commented 4 years ago

Please refer to the requirements in the readme, are you running Elasticsearch at localhost port 9200? If you are running ES on a different host or port, update the stocksight config.

r3v1 commented 4 years ago

Sorry, I was not familiar with Elastic Search engine. I forgot running in the background. It works.