diff --git a/frontend/src/hooks/useWebRTC.js b/frontend/src/hooks/useWebRTC.js index 60c4685..618679b 100644 --- a/frontend/src/hooks/useWebRTC.js +++ b/frontend/src/hooks/useWebRTC.js @@ -1,20 +1,13 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { getSocket } from '../services/socket'; -// WebRTC configuration with STUN servers +// WebRTC configuration with STUN servers for NAT traversal const rtcConfig = { iceServers: [ { urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:stun1.l.google.com:19302' }, { urls: 'stun:stun2.l.google.com:19302' }, ], - iceTransportPolicy: 'all', // Use all candidates (host, srflx, relay) - iceCandidatePoolSize: 10, // Pre-gather candidates -}; - -// Alternative config for localhost testing (no STUN) -const rtcConfigLocalhost = { - iceServers: [], // No STUN - use only host candidates for localhost }; // File chunk size (16KB recommended for WebRTC DataChannel) @@ -68,10 +61,10 @@ export const useWebRTC = (matchId, userId) => { return peerConnectionRef.current; } - // Use localhost config for testing (no STUN servers) - const pc = new RTCPeerConnection(rtcConfigLocalhost); + // Use full config with STUN servers for production + const pc = new RTCPeerConnection(rtcConfig); peerConnectionRef.current = pc; - console.log('🔧 Using rtcConfigLocalhost (no STUN servers)'); + console.log('🔧 Using rtcConfig with STUN servers for NAT traversal'); // ICE candidate handler pc.onicecandidate = (event) => {