Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Python to Client Python Q/A (INCLUDE FULL SCRIPTS!) #1078

Closed
Kakcalu13 opened this issue Mar 25, 2024 · 0 comments
Closed

Server Python to Client Python Q/A (INCLUDE FULL SCRIPTS!) #1078

Kakcalu13 opened this issue Mar 25, 2024 · 0 comments

Comments

@Kakcalu13
Copy link

I spent a good 5 days on this project. It is HAS to be mainly due to my lack of experience and knowledge.

Here's what I am able to completed:

The server and client will use WebSockets. ✅
The client will send an offer to the server through WebSocket. ✅
The server will receive the offer and send an answer to the client through ws. ✅
The client will receive the answer. ✅
The client will send ICE manually through ws (MANUAL ONLY: you will see this in the code snippet I'll share shortly). ⚠️
The data channel should open. 🛑 (Couldn't reach to this point on python to python)

The above setup works for communication between Python and JavaScript (JS) clients and the Python server. It's functional and implemented in the current server.py.

The issue arises when communicating between two Python instances (Let's call it Py2Py). There's no 'ICE generator' available for Py2Py, unlike in JavaScript, where it's automatically passed. So, I manually update the ICE as shown below:

                gatherer = RTCIceGatherer()
                await gatherer.gather()
                local_candidates = gatherer.getLocalCandidates()
                print(local_candidates[0])
                candidate_dict = {"foundation": local_candidates[0].foundation,
                                  "component": int(local_candidates[0].component),
                                  "protocol": local_candidates[0].protocol,
                                  "priority": int(local_candidates[0].priority),
                                  "ip": local_candidates[0].ip,
                                  "port": int(local_candidates[0].port),
                                  "type": local_candidates[0].type,
                                  "sdpMid": 0,  # I swear if this bites me in the future...
                                  "sdpMLineIndex": 0,
                                  "relatedAddress": local_candidates[0].relatedAddress,
                                  "relatedPort": local_candidates[0].relatedPort,
                                  'python': 1}
                data = {"type": "candidate", "candidate": candidate_dict}
                await websocket.send(json.dumps(data))

This manual part helped me move forward, but unfortunately, the data channel remains unopened without any result.

The communication between JS and Python works flawlessly, EVEN with messages printed from JS or 'data channel opened' output displayed in Python.

Now, the question is: How can we generate ICE data for the python server to obtain? My manual ICE update might not be effective.

I've included the full scripts in the attached zip for those interested in getting new idea on their own Py2Py project.

troubleshoot.zip

P.S.

I tried to put this discussion and it won't let me post there. can you transfer this to discussion? This belongs to discussion

@aiortc aiortc locked and limited conversation to collaborators May 21, 2024
@jlaine jlaine converted this issue into discussion #1100 May 21, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant