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
Broken Pipe Error while uploading playlist cover #633
Comments
I think this is because you are uploading an image that's more than 256KB
We could definitely catch that exception and display a proper error message. A PR that does that is welcome! |
I'll start working on this. Should I fix it on the "v3" branch only? |
Awesome. Nope, that's a fix for v2, so please use the main branch |
(Running Windows 10, Python 3.7.9) I couldn't reproduce this exact error. The "closest" I got was:
That happened when I uploaded the image generated by:
Which generated a 1.49 MB image. |
I ran some other tests. I uploaded the image generated by:
Which generated a 188 KB image. It uploaded correctly. But when I generated one by running:
Which generated a 191 KB image, it failed with the following error:
Which occurred while handling the following:
So, apparently it failed to upload an image that was smaller than 256 KB. It's because the maximum payload size is 256 KB, not only just the image, right? Am I testing it correctly? |
I wonder if the size (width x height) matters too? In your case 10000px looks too high. For example, I think the image must be minimum 300x300px to be uploaded manually. Maybe there is also a maximum limit To get random images in code, I like to use the dog API https://dog.ceo/dog-api/ 🐶 |
@stephanebruckert Were you able to reproduce the error? |
Whenever I want to upload a new playlist cover I am confronted with a broken pipe error.
`
with open(readConfig("mainImg"), "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
`
Which returns:
`
Traceback (most recent call last):
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 913, in _send_output
self.send(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 885, in send
self.sock.sendall(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 886, in sendall
v = self.send(data[count:])
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 856, in send
return self._sslobj.write(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 581, in write
return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 727, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/util/retry.py", line 410, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 677, in urlopen
chunked=chunked,
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1083, in request
self._send_request(method, url, body, headers)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request
self.endheaders(body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders
self._send_output(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 913, in _send_output
self.send(message_body)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 885, in send
self.sock.sendall(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 886, in sendall
v = self.send(data[count:])
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 856, in send
return self._sslobj.write(data)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/ssl.py", line 581, in write
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "SpotipyTest.py", line 219, in
sp.playlist_upload_cover_image(mainPlaylistID, encoded_string)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/spotipy/client.py", line 694, in playlist_upload_cover_image
content_type="image/jpeg",
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/spotipy/client.py", line 306, in _put
return self._internal_call("PUT", url, payload, kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/spotipy/client.py", line 242, in _internal_call
timeout=self.requests_timeout, **args
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))
`
The text was updated successfully, but these errors were encountered: