aiortc: 'Absolute Send Time' WebRTC extension bug

Hi, I get the following warning upon the successfull connection of the two peers (but in fact it is an error since it prevent completely the tracks to be sent and received):

[WARNING][2022-06-28 13:00:29,863](72026)aiortc.rtcdtlstransport: RTCDtlsTransport(client) Traceback (most recent call last):
  File "/home/bob/ws/modules/streaming-module/venv/lib/python3.8/site-packages/aiortc/", line 531, in __run
    await self._recv_next()
  File "/home/bob/ws/modules/streaming-module/venv/lib/python3.8/site-packages/aiortc/", line 630, in _recv_next
    await self._handle_rtp_data(data, arrival_time_ms=arrival_time_ms)
  File "/home/bob/ws/modules/streaming-module/venv/lib/python3.8/site-packages/aiortc/", line 575, in _handle_rtp_data
    packet = RtpPacket.parse(data, self._rtp_header_extensions_map)
  File "/home/bob/ws/modules/streaming-module/venv/lib/python3.8/site-packages/aiortc/", line 710, in parse
    packet.extensions = extensions_map.get(extension_profile, extension_value)
  File "/home/bob/ws/modules/streaming-module/venv/lib/python3.8/site-packages/aiortc/", line 89, in get
    values.abs_send_time = unpack("!L", b"\00" + x_value)[0]
struct.error: unpack requires a buffer of 4 bytes

I investigated a bit and I understood that is caused by the RTP extension “Absolute Send Time” ( In the specification it is written that this extension is 4 bytes long, but the code in aiortc/ seems to ignore this and try to get the extension value as for any other extension. Then this value is unpacked but being too short an exception from the struct package is thrown. You think all this I supposed is right? I can try patching it and sending you a first fix. Have a great day

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Hi, is there something new to update regarding this one? I experience the same thing when I try to receive the rtp_data