Open miguelmota opened 6 years ago
This response is usually due to a network error - can you confirm that you have an internet connection by running ping www.google.com? If you have a good connection, you should see: PING google.com (216.58.218.14): 56 data bytes 64 bytes from 216.58.218.14: icmp_seq=0 ttl=55 time=9.100 ms
While following the basic tutorial and running
from ISStreamer.Streamer import Streamer
streamer = Streamer(bucket_name="", bucket_key="", access_key="", debug_level=2)
streamer.log("test", "hi")
streamer.log("temperature", 32)
streamer.close()
I was getting the ship: ISStreamer failed to ship after a number of attempts error only when using a Jupyter notebook. I switched to PyCharm and the same code worked perfectly.
@charliechaf and when you tried it in the Jupyter notebook, did you ensure your bucket_key
and access_key
where properly set?
@davidsulpy yes, I'm sure. I just tested it again. The streamer works perfectly in Pycharm but when running in Jupyter it gives me the error.
@charliechaf can you paste your entire output from running this? I just verified in my own jupyter notebook and it looks like it works well for me, see the attached screenshot
yep. Here is the screenshot with the error message.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 130, in __ship
conn.request('POST', resource, json.dumps(contents), headers)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 130, in __ship
conn.request('POST', resource, json.dumps(contents), headers)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 130, in __ship
conn.request('POST', resource, json.dumps(contents), headers)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 177, in __create_bucket
self.ship_to_api("/api/buckets", {'bucketKey': new_bucket_key, 'bucketName': new_bucket_name})
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 173, in ship_to_api
__ship(3)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 171, in __ship
__ship(retry_attempts, 1)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 171, in __ship
__ship(retry_attempts, 1)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 171, in __ship
__ship(retry_attempts, 1)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ISStreamer/Streamer.py", line 122, in __ship
self.MissedEvents.write("{}\n".format(json.dumps(contents)))
ValueError: I/O operation on closed file.
Hey @charliechaf, thanks for pasting, that's very helpful. The error that you're getting is related to the TLS negotiation that the library does through python under the hood.
The machine running your jupyter book may simply not have a cert_bundle or the one that it has is specialized or old. Initial State's streaming endpoint uses AWS as the certificate authority, so you should be able to solve this by downloading the public certs for AWS CA Roots and reference them in your system before running the python.
Here is a link to the AWS Certs: https://www.amazontrust.com/repository/ Here is a link to Amazon Root CA 1 (which is the root of our cert chain): https://www.amazontrust.com/repository/AmazonRootCA1.pem And here is a link to a RedHat article that explains some ways to test this and why it happens: https://access.redhat.com/articles/2039753
Specifically, they use this code:
#!/usr/bin/env python
try:
import urllib2 #python2
except:
import urllib.request as urllib2 #python3
import sys
req = urllib2.Request(sys.argv[1], headers={'User-Agent':'Mozilla/5.0'})
urllib2.urlopen(req)
and this command to test:
$ SSL_CERT_FILE=/etc/rhsm/ca/redhat-uep.pem python urllib2-test.py https://cdn.redhat.com/
You could simply replace the redhat.com url with this url to test our streaming endpoint directly:
$ SSL_CERT_FILE=/etc/rhsm/ca/redhat-uep.pem python urllib2-test.py https://groker.init.st/version