I was trying get the media of a submission that had a media as image using Praw. As I run the code I got two error that I could not solve:
prawcore.exceptions.RequestException: error with request ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
Although I also try to convert the byte code of the image to a PIL image and then to display it, the errors occur on a earlier stage, therefore I think that there is not connection between the error and PIL. I also thought that it was related to the minutely 100 API limit, but I only do one request in my code. I would be somewhat grateful if someone helped me to solve the issue.
The code:
client=praw.Reddit(
client_id=os.getenv("client_id"),
client_secret=os.getenv("client_secret"),
username=os.getenv("UNAME"),
password=os.getenv("password"),
user_agent="bot info"
)
sub:praw.reddit.Submission=client.submission(id="some id")
resp=client.get(sub.url)
img=Image.open(BytesIO(resp.content))
img.show()
Note : The imports have been done on a previous part of the code
I expect seeing help to fix the Connection Error so that the image gets displayed when the code is run.