aioxmpp icon indicating copy to clipboard operation
aioxmpp copied to clipboard

OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF') on stream shutdown

Open Terbau opened this issue 6 years ago • 4 comments

Code:

async def connect_xmpp(loop, token, id):
    jid = aioxmpp.JID.fromstr(f"{id}@prod.ol.epicgames.com")

    client = aioxmpp.PresenceManagedClient(
        jid,
        aioxmpp.make_security_layer(token, no_verify=True),
        override_peer=[("xmpp-service-prod.ol.epicgames.com", 5222, aioxmpp.connector.STARTTLSConnector())]
    )

    async with client.connected() as stream:
        print("Connected")
        await asyncio.sleep(5)

When stream is shut down this is output to the console:

Connected
Fatal read error on STARTTLS transport
protocol: <aioxmpp.protocol.XMLStream object at 0x04A05330>
transport: <aioopenssl.STARTTLSTransport object at 0x04497370>
Traceback (most recent call last):
  File "C:\Users\brage\AppData\Local\Programs\Python\Python37-32\lib\site-packages\aioopenssl\__init__.py", line 459, in _read_ready
    data = self._sock.recv(self.MAX_SIZE)
  File "C:\Users\brage\AppData\Local\Programs\Python\Python37-32\lib\site-packages\OpenSSL\SSL.py", line 1791, in recv
    self._raise_ssl_error(self._ssl, result)
  File "C:\Users\brage\AppData\Local\Programs\Python\Python37-32\lib\site-packages\OpenSSL\SSL.py", line 1640, in _raise_ssl_error
    raise SysCallError(-1, "Unexpected EOF")
OpenSSL.SSL.SysCallError: (-1, 'Unexpected EOF')

I did some digging and found someone already had a similar issue. This was supposed to be fixed by checking if the stream is in a shutdown state. However, the state of the stream is _State.TLS_OPEN when this error is raised.

Terbau avatar Jun 30 '19 13:06 Terbau

I guess it really doesnt matter that much so I just handle the exception in the asyncio exception handler for now.

Terbau avatar Jun 30 '19 22:06 Terbau

Sorry for the delay, I was busy publishing another project.

What is the impact of this bug? The other bug was harmless in the sense that it was happening during connection shutdown and thus irrelevant (just a noisy log message).

Is this bug more impactful, and if so, in which way?

horazont avatar Jul 02 '19 17:07 horazont

Its nothing more than just noisy. For now I just handle it with loop.set_exception_handler(). You decide if its worth investigating further :)

Terbau avatar Jul 02 '19 17:07 Terbau

Ok thanks. I’ll of course investigate and find a way to silence this properly, but it won’t have super-high priority for now given that it’s just noise.

horazont avatar Jul 02 '19 18:07 horazont