uvloop icon indicating copy to clipboard operation
uvloop copied to clipboard

SSL connection error while debug is enabled

Open ankogan opened this issue 4 years ago • 1 comments

  • uvloop version: 0.15.2
  • Python version: 3.7.3
  • Platform: Debian GNU/Linux 10
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: yes, error in uvloop code

Sometimes when asyncio debug enabled (and connection is closed before starting SSL handshake? ) I got the error:

protocol: <uvloop.loop.SSLProtocol object at 0x7f69c01f4a20>
transport: <TCPTransport closed=False reading=False 0x16a0dc8>
Traceback (most recent call last):
  File "uvloop/handles/stream.pyx", line 987, in uvloop.loop.__uv_stream_buffered_on_read
  File "uvloop/loop.pyx", line 107, in uvloop.loop.run_in_context1
  File "uvloop/sslproto.pyx", line 379, in uvloop.loop.SSLProtocol.buffer_updated
  File "uvloop/sslproto.pyx", line 505, in uvloop.loop.SSLProtocol._do_handshake
  File "uvloop/sslproto.pyx", line 531, in uvloop.loop.SSLProtocol._on_handshake_complete
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

Looks like you should check if handshake is started before getting _handshake_start_time sslproto.pyx:

        if self._loop.get_debug():
            dt = self._loop.time() - self._handshake_start_time
            aio_logger.debug("%r: SSL handshake took %.1f ms", self, dt * 1e3)

ankogan avatar Oct 27 '21 12:10 ankogan

@fantix please take a look.

1st1 avatar Oct 27 '21 15:10 1st1