Skip to content

[Bug]: Lỗi 443 khi lấy dữ liệu CafeF #189

@NATien1999

Description

@NATien1999

Mô tả lỗi

Lỗi phát sinh khi lấy dữ liệu giao dịch khối ngoại (Sau khi chạy 6 phút):

TimeoutError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/urllib3/connection.py in _new_conn(self)
197 try:
--> 198 sock = connection.create_connection(
199 (self._dns_host, self.port),

22 frames
TimeoutError: [Errno 110] Connection timed out

The above exception was the direct cause of the following exception:

ConnectTimeoutError Traceback (most recent call last)
ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7cbe32ff8250>, 'Connection to s.cafef.vn timed out. (connect timeout=None)')

The above exception was the direct cause of the following exception:

MaxRetryError Traceback (most recent call last)
MaxRetryError: HTTPSConnectionPool(host='s.cafef.vn', port=443): Max retries exceeded with url: /Ajax/PageNew/DataHistory/GDKhoiNgoai.ashx?Symbol=MSN&StartDate=01/02/2024&EndDate=11/08/2024&PageIndex=1&PageSize=311 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7cbe32ff8250>, 'Connection to s.cafef.vn timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

ConnectTimeout Traceback (most recent call last)
ConnectTimeout: HTTPSConnectionPool(host='s.cafef.vn', port=443): Max retries exceeded with url: /Ajax/PageNew/DataHistory/GDKhoiNgoai.ashx?Symbol=MSN&StartDate=01/02/2024&EndDate=11/08/2024&PageIndex=1&PageSize=311 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7cbe32ff8250>, 'Connection to s.cafef.vn timed out. (connect timeout=None)'))

The above exception was the direct cause of the following exception:

RetryError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/tenacity/init.py in exc_check(rs)
419 if self.reraise:
420 raise retry_exc.reraise()
--> 421 raise retry_exc from fut.exception()
422
423 self._add_action_func(exc_check)

RetryError: RetryError[<Future at 0x7cbe336b5150 state=finished raised ConnectTimeout>]

Lỗi phát sinh khi lấy dữ liệu giao dịch tự doanh (Sau khi chạy 6 phút):

TimeoutError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/urllib3/connection.py in _new_conn(self)
197 try:
--> 198 sock = connection.create_connection(
199 (self._dns_host, self.port),

22 frames
TimeoutError: [Errno 110] Connection timed out

The above exception was the direct cause of the following exception:

ConnectTimeoutError Traceback (most recent call last)
ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7cbe32feac90>, 'Connection to s.cafef.vn timed out. (connect timeout=None)')

The above exception was the direct cause of the following exception:

MaxRetryError Traceback (most recent call last)
MaxRetryError: HTTPSConnectionPool(host='s.cafef.vn', port=443): Max retries exceeded with url: /Ajax/PageNew/DataHistory/GDTuDoanh.ashx?Symbol=MSN&StartDate=01/02/2024&EndDate=11/08/2024&PageIndex=1&PageSize=311 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7cbe32feac90>, 'Connection to s.cafef.vn timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

ConnectTimeout Traceback (most recent call last)
ConnectTimeout: HTTPSConnectionPool(host='s.cafef.vn', port=443): Max retries exceeded with url: /Ajax/PageNew/DataHistory/GDTuDoanh.ashx?Symbol=MSN&StartDate=01/02/2024&EndDate=11/08/2024&PageIndex=1&PageSize=311 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7cbe32feac90>, 'Connection to s.cafef.vn timed out. (connect timeout=None)'))

The above exception was the direct cause of the following exception:

RetryError Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/tenacity/init.py in exc_check(rs)
419 if self.reraise:
420 raise retry_exc.reraise()
--> 421 raise retry_exc from fut.exception()
422
423 self._add_action_func(exc_check)

RetryError: RetryError[<Future at 0x7cbe32feb550 state=finished raised ConnectTimeout>]

=>> Mới chỉ thử giao dịch khối ngoại và tự doanh, những câu lệnh khác từ cafef chưa được thử

Cách tái hiện lại lỗi để xử lý

Bước 1: Khởi tạo đối tượng giao dịch
from vnstock_data import Trading
trading = Trading(symbol='MSN', source='cafef')
START_DATE = '2024-01-02'
END_DATE = '2024-11-08'

Bước 2: Chạy lệnh giao dịch khối ngoại và tự doanh (Gặp lỗi ở đây):
Khối ngoại: trading.foreign_trade(start=START_DATE, end=END_DATE)
Tự doanh: trading.prop_trade(start=START_DATE, end=END_DATE)

Thông báo lỗi hoặc logs

Mong muốn đạt được

Mã hoạt động bình thường

Ảnh chụp màn hình

Image

Image

Môi trường

Google Colab

Hệ điều hành

Windows

Phiên bản

Không rõ

Phiên bản Python

3.11.13

Môi trường ảo

Không

Xác nhận

  • Tôi đã kiểm tra thông tin và xác nhận lỗi này chưa được báo cáo trước đây

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions