BennyThadikaran / eod2

A fully automated script to download and update NSE EOD Historical stock, index and delivery data with added features
GNU General Public License v3.0
57 stars 18 forks source link

getting connection error #146

Closed rameshmknd closed 3 months ago

rameshmknd commented 3 months ago

H:\python\eod2\src>py init.py CRITICAL: Unhandled exception Traceback (most recent call last): File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn conn.connect() File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 414, in connect self.sock = ssl_wrapsocket( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl.py", line 449, in ssl_wrap_socket ssl_sock = _ssl_wrap_socketimpl( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 512, in wrap_socket return self.sslsocket_class._create( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1070, in _create self.do_handshake() File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1341, in do_handshake self._sslobj.do_handshake() ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen retries = retries.increment( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\retry.py", line 550, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\packages\six.py", line 769, in reraise raise value.with_traceback(tb) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request self._validate_conn(conn) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn conn.connect() File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\connection.py", line 414, in connect self.sock = ssl_wrapsocket( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl.py", line 449, in ssl_wrap_socket ssl_sock = _ssl_wrap_socketimpl( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\urllib3\util\ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 512, in wrap_socket return self.sslsocket_class._create( File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1070, in _create self.do_handshake() File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1341, in do_handshake self._sslobj.do_handshake() urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "H:\python\eod2\src\init.py", line 34, in special_sessions = defs.downloadSpecialSessions() File "H:\python\eod2\src\defs\defs.py", line 157, in downloadSpecialSessions res = requests.get(f"{base_url}/main/special_sessions.txt") File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, kwargs) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, kwargs) File "C:\Users\JashvikKrishna\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

BennyThadikaran commented 3 months ago

Hi, This should be a temporary issue. Just delete the src/nse_cookies.pkl file and try again.

I can try and catch the exception log the error and print something useful like Please try again later.

rameshmknd commented 3 months ago

H:\python\eod2\src>py init.py INFO: Downloading Files INFO: Sat, 08 Jun 2024: Market Closed

INFO: Downloading Files INFO: Starting Data Sync INFO: EOD sync complete INFO: ### Nifty PE at 22.12 ### INFO: Index sync complete. INFO: Making adjustments for splits and bonus INFO: MOTILALOFS: bonus 3:1 INFO: Cleaning up files INFO: 1 files deleted INFO: 10 Jun 2024: Done

INFO: Updating NSE EQUITY actions INFO: Updating NSE SME actions INFO: Downloading Files INFO: Starting Data Sync INFO: EOD sync complete INFO: ### Nifty PE at 22.13 ### INFO: Index sync complete. INFO: Making adjustments for splits and bonus INFO: Cleaning up files INFO: 0 files deleted INFO: 11 Jun 2024: Done

INFO: All Up To Date

H:\python\eod2\src> not sure , but it worked without delete now