IOError: [Errno socket error] [Errno 8] _ssl.c: 504: EOF occurred in violation of protocol

0
Hello, I'm running a simple python code (2.7.3) to throw a message through webhook in Discord and I'm encountering the following error:

  urlopen(url).read()

  File "C:\Python27\lib\urllib.py", line 86, in urlopen
    return opener.open(url)
  File "C:\Python27\lib\urllib.py", line 207, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 436, in open_https
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 954, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 814, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 776, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1161, in connect
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
  File "C:\Python27\lib\ssl.py", line 381, in wrap_socket
    ciphers=ciphers)
  File "C:\Python27\lib\ssl.py", line 143, in __init__
    self.do_handshake()
  File "C:\Python27\lib\ssl.py", line 305, in do_handshake
    self._sslobj.do_handshake()

IOError: [Errno socket error] [Errno 8] _ssl.c:504: EOF occurred in violation of protocol

The code you are running is this:

from urllib import urlopen
url = 'https://minhaurl.com/webhook.php'
urlopen(url).read()

Note: There is no error in the PHP file because I used it before. Could someone help me?

    
asked by anonymous 05.10.2018 / 22:22

1 answer

0

The problem is that you are trying to use https and not http , and for this, you need several installed and upgraded version libs. Python 2.7.3 is old (it was released over 6 years ago) and a lot has changed in that field since it was released.

Encryption technology (ssl) has been updated several times in this period. Try updating your python to the newer version. If you have pyOpenSSL, upgrade it too.

    
05.10.2018 / 22:51