crossbario / crossbario/autobahn-python

Unhandled exception when closing ssl connection with SIGINT

Open
#972 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

asyncio bug needs-upstream wamp
Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

I use typical setup with

from autobahn.asyncio.component import Component, run

comp = Component(...)

run([comp])

where connection is over "wss://" protocol.

When hitting Ctrl+C (sending SIGINT) this is what happens:

^C2018-03-29T11:12:48 Shutting down due to SIGINT
2018-03-29T11:12:48 Fatal write error on socket transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f14e1c62978>
transport: <_SelectorSocketTransport fd=6>
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 761, in write
    n = self._sock.send(data)
OSError: [Errno 9] Bad file descriptor

2018-03-29T11:12:48 Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f14e1c62978>
transport: <_SelectorSocketTransport closing fd=6>
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 761, in write
    n = self._sock.send(data)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/sslproto.py", line 646, in _process_write_backlog
    self._transport.write(chunk)
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 765, in write
    self._fatal_error(exc, 'Fatal write error on socket transport')
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 645, in _fatal_error
    self._force_close(exc)
  File "/usr/lib64/python3.6/asyncio/selector_events.py", line 657, in _force_close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 574, in call_soon
    self._check_closed()
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 357, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the asyncio component entry point shown in the example, especially shutdown triggered by SIGINT, and reproduce the failure over wss://. Review the shutdown sequence alongside the asyncio sslproto.py and selector_events.py traceback; done means closing the connection on SIGINT no longer emits the unhandled transport errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.