Stun/Turn server delaying to get icecandies event
We are facing a significant delay (approximately 30 seconds) in gathering ICE candidates when using Cloudflare TURN/STUN servers, but the issue only occurs in a server-side RTCPeerConnection (Node.js).
This delay is consistently observed under these conditions:
When the server is accessed via a VPN
When the connection originates from a European country
In contrast, the ICE candidates are received almost instantly when connections are made from Bangladesh, suggesting the issue is likely region or routing-related.
We are using WebRTC to create a browser-to-server (Node.js) connection for an AI voice call application.
On both frontend and backend, we retrieve ICE server credentials via Cloudflare’s generate-ice-servers endpoint:
const getIceServer = await fetch(
https://rtc.live.cloudflare.com/v1/turn/keys/${TURN_KEY_ID}/credentials/generate-ice-servers
,
{
method: "POST",
headers: {
"Authorization": Bearer ${TURN_KEY_API_TOKEN}
,
"Content-Type": "application/json"
},
body: JSON.stringify({ ttl: 3600 })
}
);
const { iceServers } = await getIceServer.json();
These ICE servers are then passed to our RTCPeerConnection like this:
const pc = new RTCPeerConnection({
iceServers: callEntry.iceServers,
iceTransportPolicy: "all",
iceCandidatePoolSize: 0
});
The delay is happening only on the server side, where the icecandidate event is either extremely delayed or does not fire at all for ~30 seconds.
Could you please investigate whether:
There are any known routing, peering, or relay issues for TURN/STUN requests from European regions or VPNs.
Any region-specific optimization or fallback configurations are recommended when using generate-ice-servers in backend (Node.js) environments0 Replies