I have seen the following issue for a while, in which case RTCPeerConnection.close() is blocked forever.
2019-04-10 16:44:51,609 [548366143488] client - event = connection_lost(None)
2019-04-10 16:44:51,610 [548366143488] client - state = CLOSED
2019-04-10 16:44:51,610 [548366143488] client x code = 1000, reason = [no reason]
2019-04-10 16:44:51,612 [548366143488] client x closing TCP connection
2019-04-10 16:44:51,613 [548366143488] finished signaling
2019-04-10 16:44:51,613 [548366143488] cleanup in progress...
2019-04-10 16:44:51,614 [548366143488] closing the peer connection...
2019-04-10 16:44:51,615 [548366143488] sender(video) > RtcpByePacket(sources=[648406895])
2019-04-10 16:44:51,616 [548366143488] sender(video) - RTCP finished
2019-04-10 16:44:51,618 [548366143488] sender(video) > RtcpByePacket(sources=[2211053875])
2019-04-10 16:44:51,618 [548366143488] sender(video) - RTCP finished
2019-04-10 16:44:51,619 [548366143488] sender(video) > RtcpByePacket(sources=[1008964769])
2019-04-10 16:44:51,620 [548366143488] sender(video) - RTCP finished
2019-04-10 16:44:51,621 [548366143488] sender(video) > RtcpByePacket(sources=[1747941862])
2019-04-10 16:44:51,621 [548366143488] sender(video) - RTCP finished
2019-04-10 16:44:51,622 [548366143488] server > AbortChunk(flags=0)
2019-04-10 16:44:51,623 [548366143488] server - State.ESTABLISHED -> State.CLOSED
2019-04-10 16:44:51,623 [548366143488] 1 - open -> closed
2019-04-10 16:44:51,624 [548366143488] controlled - completed -> closed
2019-04-10 16:44:51,624 [548366143488] iceConnectionState changed to closed
2019-04-10 16:44:51,625 [548366143488] Connection(10) protocol(14) connection_lost(None)
2019-04-10 16:44:51,626 [548366143488] Connection(10) protocol(15) connection_lost(None)
2019-04-10 16:44:51,627 [548366143488] Connection(10) protocol(16) connection_lost(None)
2019-04-10 16:44:51,628 [548366143488] Connection(10) protocol(17) connection_lost(None)
2019-04-10 16:44:51,629 [548366143488] Connection(10) protocol(18) connection_lost(None)
2019-04-10 16:44:51,629 [548366143488] Connection(10) protocol(19) connection_lost(None)
2019-04-10 16:44:51,631 [548366143488] turn/udp > ('tk-turn1.xirsys.com', 80) Message(message_method=Method.REFRESH, message_class=Class.REQUEST, transaction_id=b'\xd0\xd5\xd5wB\xbd\xc5\xc6\x146\xd2e')
2019-04-10 16:44:51,666 [548366143488] turn/udp < ('54.199.237.77', 80) Message(message_method=Method.REFRESH, message_class=Class.ERROR, transaction_id=b'\xd0\xd5\xd5wB\xbd\xc5\xc6\x146\xd2e')
2019-04-10 16:44:51,667 [548366143488] Task exception was never retrieved
future: <Task finished coro=<TurnClientMixin.delete() done, defined at /home/nvidia/Downloads/aioice/aioice/turn.py:130> exception=TransactionFailed(Message(message_method=Method.REFRESH, message_class=Class.ERROR, transaction_id=b'\xd0\xd5\xd5wB\xbd\xc5\xc6\x146\xd2e'))>
Traceback (most recent call last):
File "/home/nvidia/Downloads/aioice/aioice/turn.py", line 141, in delete
await self.request(request)
File "/home/nvidia/Downloads/aioice/aioice/turn.py", line 173, in request
return await transaction.run()
File "/home/nvidia/Downloads/aioice/aioice/stun.py", line 250, in run
return await self.__future
aioice.exceptions.TransactionFailed: STUN transaction failed (438 - Wrong nonce^@)
The root cause is, as explicitly the error message says, the loop thread dies because of the uncaught exception.
try:
await self.request(request)
except exceptions.TransactionFailed:
logger.debug('the turn allocation deletion request failed')
The output when the TransactionFailed was raised.
2019-04-10 17:09:59,577 [547505090560] client - event = connection_lost(None)
2019-04-10 17:09:59,578 [547505090560] client - state = CLOSED
2019-04-10 17:09:59,579 [547505090560] client x code = 1000, reason = [no reason]
2019-04-10 17:09:59,580 [547505090560] client x closing TCP connection
2019-04-10 17:09:59,581 [547505090560] finished signaling
2019-04-10 17:09:59,582 [547505090560] cleanup in progress...
2019-04-10 17:09:59,583 [547505090560] closing the peer connection...
2019-04-10 17:09:59,584 [547505090560] sender(video) > RtcpByePacket(sources=[2531309811])
2019-04-10 17:09:59,585 [547505090560] sender(video) - RTCP finished
2019-04-10 17:09:59,587 [547505090560] sender(video) > RtcpByePacket(sources=[1615847512])
2019-04-10 17:09:59,588 [547505090560] sender(video) - RTCP finished
2019-04-10 17:09:59,590 [547505090560] sender(video) > RtcpByePacket(sources=[1579158080])
2019-04-10 17:09:59,591 [547505090560] sender(video) - RTCP finished
2019-04-10 17:09:59,593 [547505090560] sender(video) > RtcpByePacket(sources=[987792055])
2019-04-10 17:09:59,593 [547505090560] sender(video) - RTCP finished
2019-04-10 17:09:59,594 [547505090560] server > AbortChunk(flags=0)
2019-04-10 17:09:59,596 [547505090560] server - State.ESTABLISHED -> State.CLOSED
2019-04-10 17:09:59,596 [547505090560] 1 - open -> closed
2019-04-10 17:09:59,597 [547505090560] controlled - completed -> closed
2019-04-10 17:09:59,597 [547505090560] iceConnectionState changed to closed
2019-04-10 17:09:59,599 [547505090560] Connection(0) protocol(0) connection_lost(None)
2019-04-10 17:09:59,600 [547505090560] Connection(0) protocol(1) connection_lost(None)
2019-04-10 17:09:59,600 [547505090560] Connection(0) protocol(2) connection_lost(None)
2019-04-10 17:09:59,601 [547505090560] Connection(0) protocol(3) connection_lost(None)
2019-04-10 17:09:59,602 [547505090560] Connection(0) protocol(4) connection_lost(None)
2019-04-10 17:09:59,603 [547505090560] Connection(0) protocol(5) connection_lost(None)
2019-04-10 17:09:59,605 [547505090560] turn/udp > ('tk-turn2.xirsys.com', 80) Message(message_method=Method.REFRESH, message_class=Class.REQUEST, transaction_id=b'z\xc7\xa3X\x17\x998\xeb\x8a\xd8\xe3\x14')
2019-04-10 17:09:59,622 [547505090560] turn/udp < ('52.194.163.111', 80) Message(message_method=Method.REFRESH, message_class=Class.ERROR, transaction_id=b'z\xc7\xa3X\x17\x998\xeb\x8a\xd8\xe3\x14')
2019-04-10 17:09:59,623 [547505090560] the turn allocation deletion request failed
2019-04-10 17:09:59,624 [547505090560] TURN allocation deleted ('172.26.15.73', 64919)
2019-04-10 17:09:59,624 [547505090560] Connection(0) protocol(6) connection_lost(None)