Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalAPI connect issue #71

Open
kevinoden opened this issue Jul 11, 2024 · 8 comments
Open

LocalAPI connect issue #71

kevinoden opened this issue Jul 11, 2024 · 8 comments

Comments

@kevinoden
Copy link

i have tried Dev, Prod, Latest but still get the following when issuing the command from jupyter notebook

from absbox import examples,API,EnginePath

i am using ubuntu

SSLError Traceback (most recent call last)
File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connectionpool.py:466, in HTTPConnectionPool._make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)
465 try:
--> 466 self._validate_conn(conn)
467 except (SocketTimeout, BaseSSLError) as e:

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connectionpool.py:1095, in HTTPSConnectionPool._validate_conn(self, conn)
1094 if conn.is_closed:
-> 1095 conn.connect()
1097 # TODO revise this, see urllib3/urllib3#2791

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connection.py:652, in HTTPSConnection.connect(self)
650 server_hostname_rm_dot = server_hostname.rstrip(".")
--> 652 sock_and_verified = _ssl_wrap_socket_and_match_hostname(
653 sock=sock,
654 cert_reqs=self.cert_reqs,
655 ssl_version=self.ssl_version,
656 ssl_minimum_version=self.ssl_minimum_version,
657 ssl_maximum_version=self.ssl_maximum_version,
658 ca_certs=self.ca_certs,
659 ca_cert_dir=self.ca_cert_dir,
660 ca_cert_data=self.ca_cert_data,
661 cert_file=self.cert_file,
662 key_file=self.key_file,
663 key_password=self.key_password,
664 server_hostname=server_hostname_rm_dot,
665 ssl_context=self.ssl_context,
666 tls_in_tls=tls_in_tls,
667 assert_hostname=self.assert_hostname,
668 assert_fingerprint=self.assert_fingerprint,
669 )
670 self.sock = sock_and_verified.socket

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connection.py:805, in _ssl_wrap_socket_and_match_hostname(sock, cert_reqs, ssl_version, ssl_minimum_version, ssl_maximum_version, cert_file, key_file, key_password, ca_certs, ca_cert_dir, ca_cert_data, assert_hostname, assert_fingerprint, server_hostname, ssl_context, tls_in_tls)
803 server_hostname = normalized
--> 805 ssl_sock = ssl_wrap_socket(
806 sock=sock,
807 keyfile=key_file,
808 certfile=cert_file,
809 key_password=key_password,
810 ca_certs=ca_certs,
811 ca_cert_dir=ca_cert_dir,
812 ca_cert_data=ca_cert_data,
813 server_hostname=server_hostname,
814 ssl_context=context,
815 tls_in_tls=tls_in_tls,
816 )
818 try:

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/util/ssl_.py:465, in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir, key_password, ca_cert_data, tls_in_tls)
463 pass
--> 465 ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
466 return ssl_sock

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/util/ssl_.py:509, in _ssl_wrap_socket_impl(sock, ssl_context, tls_in_tls, server_hostname)
507 return SSLTransport(sock, ssl_context, server_hostname)
--> 509 return ssl_context.wrap_socket(sock, server_hostname=server_hostname)

File ~/anaconda3/envs/env311/lib/python3.11/ssl.py:517, in SSLContext.wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
511 def wrap_socket(self, sock, server_side=False,
512 do_handshake_on_connect=True,
513 suppress_ragged_eofs=True,
514 server_hostname=None, session=None):
515 # SSLSocket class handles server_hostname encoding before it calls
516 # ctx._wrap_socket()
--> 517 return self.sslsocket_class._create(
518 sock=sock,
519 server_side=server_side,
520 do_handshake_on_connect=do_handshake_on_connect,
521 suppress_ragged_eofs=suppress_ragged_eofs,
522 server_hostname=server_hostname,
523 context=self,
524 session=session
525 )

File ~/anaconda3/envs/env311/lib/python3.11/ssl.py:1104, in SSLSocket._create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
1103 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1104 self.do_handshake()
1105 except:

File ~/anaconda3/envs/env311/lib/python3.11/ssl.py:1382, in SSLSocket.do_handshake(self, block)
1381 self.settimeout(None)
-> 1382 self._sslobj.do_handshake()
1383 finally:

SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1006)

During handling of the above exception, another exception occurred:

SSLError Traceback (most recent call last)
File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connectionpool.py:789, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
788 # Make the request on the HTTPConnection object
--> 789 response = self._make_request(
790 conn,
791 method,
792 url,
793 timeout=timeout_obj,
794 body=body,
795 headers=headers,
796 chunked=chunked,
797 retries=retries,
798 response_conn=response_conn,
799 preload_content=preload_content,
800 decode_content=decode_content,
801 **response_kw,
802 )
804 # Everything went great!

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connectionpool.py:490, in HTTPConnectionPool._make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)
489 new_e = _wrap_proxy_error(new_e, conn.proxy.scheme)
--> 490 raise new_e
492 # conn.request() calls http.client.*.request, not the method in
493 # urllib3.request. It also calls makefile (recv) on the socket.

SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1006)

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

MaxRetryError Traceback (most recent call last)
File ~/anaconda3/envs/env311/lib/python3.11/site-packages/requests/adapters.py:667, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
666 try:
--> 667 resp = conn.urlopen(
668 method=request.method,
669 url=url,
670 body=request.body,
671 headers=request.headers,
672 redirect=False,
673 assert_same_host=False,
674 preload_content=False,
675 decode_content=False,
676 retries=self.max_retries,
677 timeout=timeout,
678 chunked=chunked,
679 )
681 except (ProtocolError, OSError) as err:

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/connectionpool.py:843, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, preload_content, decode_content, **response_kw)
841 new_e = ProtocolError("Connection aborted.", new_e)
--> 843 retries = retries.increment(
844 method, url, error=new_e, _pool=self, _stacktrace=sys.exc_info()[2]
845 )
846 retries.sleep()

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/urllib3/util/retry.py:519, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
518 reason = error or ResponseError(cause)
--> 519 raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
521 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='absbox.org', port=443): Max retries exceeded with url: /api/latest/version (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1006)')))

During handling of the above exception, another exception occurred:

SSLError Traceback (most recent call last)
File ~/anaconda3/envs/env311/lib/python3.11/site-packages/absbox/client.py:215, in API.post_init(self)
214 try:
--> 215 _r = requests.get(f"{self.url}/{Endpoints.Version.value}", verify=False, timeout=5, headers = {"Origin":"http://localhost:8001"}).text
216 except (ConnectionRefusedError, ConnectionError):

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/requests/api.py:73, in get(url, params, **kwargs)
63 r"""Sends a GET request.
64
65 :param url: URL for the new :class:Request object.
(...)
70 :rtype: requests.Response
71 """
---> 73 return request("get", url, params=params, **kwargs)

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/requests/api.py:59, in request(method, url, **kwargs)
58 with sessions.Session() as session:
---> 59 return session.request(method=method, url=url, **kwargs)

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/requests/sessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
588 send_kwargs.update(settings)
--> 589 resp = self.send(prep, **send_kwargs)
591 return resp

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/requests/sessions.py:703, in Session.send(self, request, **kwargs)
702 # Send the request
--> 703 r = adapter.send(request, **kwargs)
705 # Total elapsed time of the request (approximately)

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/requests/adapters.py:698, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
696 if isinstance(e.reason, _SSLError):
697 # This branch is for urllib3 v1.22 and later.
--> 698 raise SSLError(e, request=request)
700 raise ConnectionError(e, request=request)

SSLError: HTTPSConnectionPool(host='absbox.org', port=443): Max retries exceeded with url: /api/latest/version (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1006)')))

During handling of the above exception, another exception occurred:

AbsboxError Traceback (most recent call last)
Cell In[12], line 2
1 # https://absbox.org/api/latest
----> 2 localAPI = API(EnginePath.PROD,check=False)

File :6, in init(self, url, lang, check)

File ~/anaconda3/envs/env311/lib/python3.11/site-packages/absbox/client.py:217, in API.post_init(self)
215 _r = requests.get(f"{self.url}/{Endpoints.Version.value}", verify=False, timeout=5, headers = {"Origin":"http://localhost:8001"}).text
216 except (ConnectionRefusedError, ConnectionError):
--> 217 raise AbsboxError(f"❌{MsgColor.Error.value}Error: Can't not connect to API server {self.url}")
218 if _r is None:
219 raise RuntimeError(f"Failed to get version from url:{self.url}")

AbsboxError: ❌[bold red]Error: Can't not connect to API server https://absbox.org/api/latest

@yellowbean
Copy link
Owner

I've just check in Debian.

The public server in Singapore looks good.

Screenshot_2024-07-12_11-47-06

Are you in the corporate network with possible restriction to SSL ?

@kevinoden
Copy link
Author

kevinoden commented Jul 12, 2024 via email

@kevinoden
Copy link
Author

kevinoden commented Jul 12, 2024 via email

@yellowbean
Copy link
Owner

OK, let me know if I can assist further .

The last resort would be using local docker image ( you run a server locally )

@kevinoden
Copy link
Author

kevinoden commented Jul 12, 2024 via email

@yellowbean
Copy link
Owner

Hi @kevinoden

I'm happy to assist further if the issue persists

@yellowbean
Copy link
Owner

yellowbean commented Sep 22, 2024

Hi, @kevinoden

How are you..

There is a new update from Hastructure project that it would ship with pre-built binaries . Then you can start own engine server locally rather than connecting to external public server

You can download these exes and run it locally in different OS ( Windows/Ubuntu/MacOS)

There is a mini guide here

Let me know anything else I can assist further.

Regards

@kevinoden
Copy link
Author

kevinoden commented Sep 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants