Ice connection state stuck in checking
See original GitHub issueHi!
I have been trying to work on handling frames from a wowza streaming server using python, i’m working since a while on this code and i cannot understand why my ice candidate still on checking state and i’m not receiving any frames or any feedback from server
I’m look for a lot of examples on this repository but i cannot reproduce the behavior on my code.
Here it’s my code.
import asyncio
import cv2
from aiortc import (
RTCIceCandidate,
MediaStreamTrack,
RTCPeerConnection,
RTCSessionDescription,
RTCConfiguration,
)
pc = RTCPeerConnection(RTCConfiguration(iceServers=[]))
@pc.on("iceconnectionstatechange")
async def on_iceconnectionstatechange():
print(f"ICE connection state is {pc.iceConnectionState}")
if pc.iceConnectionState == "failed":
await pc.close()
if pc.iceConnectionState == "checking":
candidates = pc.localDescription.sdp.split("\r\n")
for candidate in candidates:
if "a=candidate:" in candidate:
print("added ice candidate")
candidate = candidate.replace("a=candidate:", "")
splitted_data = candidate.split(" ")
remote_ice_candidate = RTCIceCandidate(
foundation=splitted_data[0],
component=splitted_data[1],
protocol=splitted_data[2],
priority=int(splitted_data[3]),
ip=splitted_data[4],
port=int(splitted_data[5]),
type=splitted_data[7],
sdpMid=0,
sdpMLineIndex=0,
)
pc.addIceCandidate(remote_ice_candidate)
@pc.on("track")
async def on_track(track):
print(f"Track {track.kind} received")
if track.kind == "video":
local_video = VideoTransformTrack(track)
pc.addTrack(local_video)
await local_video.recv()
@track.on("ended")
def on_ended():
print(f"Track {track.kind} ended")
@pc.on("datachannel")
async def on_datachannel(channel):
print(f"changed datachannel to {channel}")
@pc.on("signalingstatechange")
async def on_signalingstatechange():
print(f"changed signalingstatechange {pc.signalingState}")
@pc.on("icegatheringstatechange")
async def on_icegatheringstatechange():
print(f"changed icegatheringstatechange {pc.iceGatheringState}")
class VideoTransformTrack(MediaStreamTrack):
"""
A video stream track that transforms frames from an another track.
"""
kind = "video"
def __init__(self, track):
super().__init__() # don't forget this!
self.track = track
async def recv(self):
print("trying to retrieve frame...")
frame = await self.track.recv()
print("framed retrieved.")
return frame
async def offer(sdp, sdp_type):
offer = RTCSessionDescription(sdp=sdp, type=sdp_type)
# handle offer
await pc.setRemoteDescription(offer)
# send answer
answer = await pc.createAnswer()
await pc.setLocalDescription(answer)
print("finished offer.")
if __name__ == "__main__":
sdp_type = "offer"
sdp = "v=0\r\no=WowzaStreamingEngine-next 948965951 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 53:21:2B:54:27:E2:4F:16:7F:A9:70:0D:21:D0:0A:DF:9D:8A:E1:A7:6B:7B:A9:2B:57:D9:42:EB:C9:7A:76:8C\r\na=group:BUNDLE video\r\na=ice-options:trickle\r\na=msid-semantic:WMS *\r\nm=video 9 RTP/SAVPF 97\r\na=rtpmap:97 H264/90000\r\na=fmtp:97 packetization-mode=1;profile-level-id=42001f;sprop-parameter-sets=Z00AH52oFAFum4CAgKAAAAMAIAAAAwMQgA==,aO48gA==\r\na=cliprect:0,0,720,1280\r\na=framesize:97 1280-720\r\na=framerate:12.0\r\na=control:trackID=1\r\nc=IN IP4 0.0.0.0\r\na=sendrecv\r\na=ice-pwd:30f8917b33a334eb74fb468068b9b492\r\na=ice-ufrag:206f59a4\r\na=mid:video\r\na=msid:{af74b9ec-8e25-42a6-829c-ef935ac422c2} {4b9b5630-3b6b-41c9-9ca9-50bf00d7be78}\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=rtcp-fb:97 ccm fir\r\na=rtcp-mux\r\na=setup:actpass\r\na=ssrc:1715144048 cname:{a4361dd7-133c-4777-90dc-671394ecafe9}\r\n"
loop = asyncio.get_event_loop()
loop.run_until_complete(offer(sdp, sdp_type))
loop.run_forever()
This is the output from the code.
Track video received
trying to retrieve frame...
changed signalingstatechange stable
changed signalingstatechange stable
changed icegatheringstatechange gathering
changed icegatheringstatechange complete
finished offer.
ICE connection state is checking
added ice candidate
added ice candidate
added ice candidate
added ice candidate
added ice candidate
added ice candidate
In this case the frame retrieved it’s never printed and the ICE connection state keeps in checking
Any feedback would be appreciated!
Cheers
Jcanabarro
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:8
Top Results From Across the Web
ICE Connection State stuck at 'checking' · Issue #35 - GitHub
My app has been working fine for months, and all of a sudden ice connection state is getting stuck at checking. Here's the...
Read more >stuck in WebRTC ICE checking state - Stack Overflow
The browser ICE connection state successfully goes to "checking" and at that point I am stuck. Question: Is the server or remote browser...
Read more >Chrome stuck in ice connection state of checking
Hi, I want to implement a server to echo the audio from Chrome. I use libnice to implement this server, and I exchanged...
Read more >516337 - WebRTC connection stuck in ice state "checking"
What went wrong? Even though WebRTC handshake was done and WebRTC signalling state was "stable", ice connection state got stuck in "checking" and...
Read more >RTCPeerConnection.iceConnectionState - Web APIs | MDN
The current state of the ICE agent and its connection. ... The ICE agent has finished gathering candidates, has checked all pairs against ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

What exactly do you expect me to do with a hard-coded SDP blob?
Well i’m always thought the forum was a guide, or at least some place we can share knowledge about related problems, i’m not here to say that the lib has some problems or something like that, no i’m just try to figure out what happens with my code, and why the have this behavior, maybe could be some problem with wowza or don’t know, maybe my code is really bad, you don’t need to answer my question if you never have this problem before, but maybe, just maybe has someone who has the same problem and figure out the solution. But this discussion will be useless and worthless.