shahinrostami / plotapi

Engaging visualisations, made easy.
https://plotapi.com
MIT License
267 stars 17 forks source link

Http issues with university firewall #42

Closed JoffJones closed 3 years ago

JoffJones commented 3 years ago

Hi there! Thanks for making this great tool. I am having similar problems to those mentioned before where the interaction with the web services isn't being authenticated (https://github.com/shahinrostami/chord/issues/20).

Is there a workaround for the latest version?

Many thanks, Joff

shahinrostami commented 3 years ago

Hi there! Thanks for making this great tool. I am having similar problems to those mentioned before where the interaction with the web services isn't being authenticated (https://github.com/shahinrostami/chord/issues/20).

Is there a workaround for the latest version?

Many thanks,

Joff

Hi Joff

I'm glad you like it.

Can you share an error and some more details?

The feature of having it work through a secured work/school network is tricky as I can't reproduce it on my end, and there is little funding to work with on this project!

JoffJones commented 3 years ago

Thank you for the quick response! Its the SSL certificate verification error referred to in previous posts. I've copied the full error below:

from chord import Chord Chord(eg_mat, ['b', 'a']).show()

SSLCertVerificationError Traceback (most recent call last) ~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 698 # Make the request on the httplib connection object. --> 699 httplib_response = self._make_request( 700 conn,

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 381 try: --> 382 self._validate_conn(conn) 383 except (SocketTimeout, BaseSSLError) as e:

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/connectionpool.py in _validate_conn(self, conn) 1009 if not getattr(conn, "sock", None): # AppEngine might not have .sock -> 1010 conn.connect() 1011

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/connection.py in connect(self) 410 --> 411 self.sock = ssl_wrap_socket( 412 sock=conn,

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/util/ssl_.py 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) 427 if send_sni: --> 428 ssl_sock = _ssl_wrap_socket_impl( 429 sock, context, tls_in_tls, server_hostname=server_hostname

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/util/ssl_.py in _ssl_wrap_socket_impl(sock, ssl_context, tls_in_tls, server_hostname) 471 if server_hostname: --> 472 return ssl_context.wrap_socket(sock, server_hostname=server_hostname) 473 else:

~/.conda/envs/networks/lib/python3.8/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 499 # ctx._wrap_socket() --> 500 return self.sslsocket_class._create( 501 sock=sock,

~/.conda/envs/networks/lib/python3.8/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session) 1039 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") -> 1040 self.do_handshake() 1041 except (OSError, ValueError):

~/.conda/envs/networks/lib/python3.8/ssl.py in do_handshake(self, block) 1308 self.settimeout(None) -> 1309 self._sslobj.do_handshake() 1310 finally:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1124)

During handling of the above exception, another exception occurred:

MaxRetryError Traceback (most recent call last) ~/.conda/envs/networks/lib/python3.8/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 438 if not chunked: --> 439 resp = conn.urlopen( 440 method=request.method,

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 754 --> 755 retries = retries.increment( 756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

~/.conda/envs/networks/lib/python3.8/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace) 572 if new_retry.is_exhausted(): --> 573 raise MaxRetryError(_pool, url, error or ResponseError(cause)) 574

MaxRetryError: HTTPSConnectionPool(host='api.shahin.dev', port=443): Max retries exceeded with url: /chordfree (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1124)')))

During handling of the above exception, another exception occurred:

SSLError Traceback (most recent call last)

in 1 from chord import Chord ----> 2 Chord(eg_mat, ['b', 'a'], credit=False).show() ~/.conda/envs/networks/lib/python3.8/site-packages/chord/__init__.py in show(self) ~/.conda/envs/networks/lib/python3.8/site-packages/chord/__init__.py in render_html(self) ~/.conda/envs/networks/lib/python3.8/site-packages/requests/api.py in post(url, data, json, **kwargs) 117 """ 118 --> 119 return request('post', url, data=data, json=json, **kwargs) 120 121 ~/.conda/envs/networks/lib/python3.8/site-packages/requests/api.py in request(method, url, **kwargs) 59 # cases, and look like a memory leak in others. 60 with sessions.Session() as session: ---> 61 return session.request(method=method, url=url, **kwargs) 62 63 ~/.conda/envs/networks/lib/python3.8/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 540 } 541 send_kwargs.update(settings) --> 542 resp = self.send(prep, **send_kwargs) 543 544 return resp ~/.conda/envs/networks/lib/python3.8/site-packages/requests/sessions.py in send(self, request, **kwargs) 653 654 # Send the request --> 655 r = adapter.send(request, **kwargs) 656 657 # Total elapsed time of the request (approximately) ~/.conda/envs/networks/lib/python3.8/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies) 512 if isinstance(e.reason, _SSLError): 513 # This branch is for urllib3 v1.22 and later. --> 514 raise SSLError(e, request=request) 515 516 raise ConnectionError(e, request=request) SSLError: HTTPSConnectionPool(host='api.shahin.dev', port=443): Max retries exceeded with url: /chordfree (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1124)')))
shahinrostami commented 3 years ago

@JoffJones Thanks for pasting that over. Does this work https://stackoverflow.com/a/43855394/29445 ?

shahinrostami commented 3 years ago

@JoffJones in the meantime, I've just added verify_ssl=False to Chord!

pip uninstall chord and then pip install chord to update to 1.0.2!

JoffJones commented 3 years ago

@shahinrostami thank you very much for the quick fix! I managed to get it working but unfortunately during testing I hit the limit on number of requests made using the free version

shahinrostami commented 3 years ago

@shahinrostami thank you very much for the quick fix! I managed to get it working but unfortunately during testing I hit the limit on number of requests made using the free version

Ah, I just noticed you said you got it working! Glad it works.