Discussions
429 Too Many Requests (from /ice -- ICE Candidates)
Hello,
Based on the example Repo here:
https://github.com/de-id/live-streaming-demo/blob/main/streaming-client-api.js
I don't see anywhere that the response from the "/ice" Endpoint is being used. It shows:
fetch(${DID_API.url}/talks/streams/${streamId}/ice .... )
The return value (looking like the below) is never used:
JavaScript
{
"status": "created",
"session_id": "AWSALB=I0uyejtkytYKBWgi3ONVyv2D+fz934HfrMYx2W7dsjg55kUz+b310V..vuuPd; Expires=Sun, 01 Oct 2023 21:47:55 GMT; Path=/; AWSALBCORS=I0uyejtk...yv2D+fz934HfrMYx2W7dsjg55kUz+b310V...4TVCjhUbpet3pXh9fIAy...wEvuuPd; Expires=Sun, 01 Oct 2023 21:47:55 GMT; Path=/; SameSite=None; Secure"
}
Does the Browser use this automatically? How? If not, then what exactly does this fetch code do?
From WebRTC documentation online, I see the use of "addIceCandidate", but I don't see this anywhere here.
Anyways, beyond this, the code ends up making a dozen or more Requests for this (i.e. onIceCandidate is executed a dozen or more times). This causes a 429 Too Many Requests error from you D-ID Server.
I'm not sure why this is, maybe because the Candidates that come through aren't being used appropriately?
Why are so many ICE Candidates being received? I even slice the iceServers so that there is always only 1 Ice Server in consideration (to see if that'd reduce the number of Requests, it didn't).
Any other thoughts or suggestions to get this to work and avoid the 429 error?
Thank you!
NOTE, I have also modified the code (to bypass "CORS" Errors during Development, to Proxy via my local NodeJS Server, Response I show above is still the Response I send back to mimic exactly what the raw "fetch" to your Server would of done.
JavaScript
function onIceCandidate(event) {
console.log('onIceCandidate', event);
if( event.candidate ) {
const { candidate, sdpMid, sdpMLineIndex } = event.candidate;
const payload = {
candidate,
sdpMid,
sdpMLineIndex,
sessionId,
};
console.log("STREAMS ICE (Client) PAYLOAD", JSON.stringify(payload));
const sendIceCandidate = async () => {
const requestOptions = { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) };
const response = await fetch( `${SERVER_ORIGIN}/api/synthetics/face/streams/${streamId}/ice`, requestOptions );
...