mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 02:43:25 +00:00
Fix answerer authorization for ICE candidates
The answerer was getting 403 Forbidden when sending ICE candidates because the server didn't know who the answerer was yet. ICE gathering starts when setLocalDescription is called, but we were calling /answer AFTER that. Fixed by sending the answer to the server BEFORE setLocalDescription: 1. Create answer SDP 2. Send answer to server (registers answererPeerId) 3. Set up ICE handler 4. Set local description (ICE gathering starts) This ensures the server has answererPeerId set before ICE candidates arrive, so they're properly authorized. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -23,15 +23,19 @@ export class AnsweringState extends PeerState {
|
|||||||
sdp: offerSdp
|
sdp: offerSdp
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Create answer
|
||||||
|
const answer = await this.peer.pc.createAnswer();
|
||||||
|
|
||||||
|
// Send answer to server BEFORE setLocalDescription
|
||||||
|
// This registers us as the answerer so ICE candidates will be accepted
|
||||||
|
await this.peer.offersApi.answer(offerId, answer.sdp!);
|
||||||
|
|
||||||
// Enable trickle ICE - set up handler before ICE gathering starts
|
// Enable trickle ICE - set up handler before ICE gathering starts
|
||||||
this.setupIceCandidateHandler();
|
this.setupIceCandidateHandler();
|
||||||
|
|
||||||
// Create answer
|
// Set local description - ICE gathering starts here
|
||||||
const answer = await this.peer.pc.createAnswer();
|
// Server already knows we're the answerer, so candidates will be accepted
|
||||||
await this.peer.pc.setLocalDescription(answer); // ICE gathering starts here
|
await this.peer.pc.setLocalDescription(answer);
|
||||||
|
|
||||||
// Send answer to server immediately (don't wait for ICE)
|
|
||||||
await this.peer.offersApi.answer(offerId, answer.sdp!);
|
|
||||||
|
|
||||||
// Transition to exchanging ICE
|
// Transition to exchanging ICE
|
||||||
const { ExchangingIceState } = await import('./exchanging-ice-state.js');
|
const { ExchangingIceState } = await import('./exchanging-ice-state.js');
|
||||||
|
|||||||
Reference in New Issue
Block a user