mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-19 08:28:10 +02:00
feat: add coturn for remote deployments (#84)
* feat: add coturn for remote deployment * Simplify remote setup * fix logic in UI
This commit is contained in:
parent
2e37c89310
commit
17409998d2
9 changed files with 326 additions and 144 deletions
|
|
@ -39,6 +39,12 @@ export const useWebSocketRTC = ({ workflowId, workflowRunId, accessToken, initia
|
|||
const useAudio = true;
|
||||
const audioCodec = 'default';
|
||||
|
||||
// TURN server configuration from environment variables (matching backend pattern)
|
||||
const turnHost = process.env.NEXT_PUBLIC_TURN_HOST;
|
||||
const turnUsername = process.env.NEXT_PUBLIC_TURN_USERNAME;
|
||||
const turnPassword = process.env.NEXT_PUBLIC_TURN_PASSWORD;
|
||||
const useTurn = !!(turnHost && turnUsername && turnPassword);
|
||||
|
||||
const audioRef = useRef<HTMLAudioElement>(null);
|
||||
const pcRef = useRef<RTCPeerConnection | null>(null);
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
|
|
@ -67,8 +73,29 @@ export const useWebSocketRTC = ({ workflowId, workflowRunId, accessToken, initia
|
|||
}, [workflowId, workflowRunId, accessToken]);
|
||||
|
||||
const createPeerConnection = () => {
|
||||
// Build ICE servers list
|
||||
const iceServers: RTCIceServer[] = [];
|
||||
|
||||
if (useStun) {
|
||||
iceServers.push({ urls: ['stun:stun.l.google.com:19302'] });
|
||||
}
|
||||
|
||||
if (useTurn && turnHost && turnUsername && turnPassword) {
|
||||
// Add TURN server with credentials from environment variables
|
||||
iceServers.push({
|
||||
urls: [
|
||||
`turn:${turnHost}:3478`, // TURN over UDP
|
||||
`turn:${turnHost}:3478?transport=tcp`, // TURN over TCP
|
||||
],
|
||||
username: turnUsername,
|
||||
credential: turnPassword
|
||||
});
|
||||
|
||||
logger.info(`TURN server configured: ${turnHost}:3478`);
|
||||
}
|
||||
|
||||
const config: RTCConfiguration = {
|
||||
iceServers: useStun ? [{ urls: ['stun:stun.l.google.com:19302'] }] : []
|
||||
iceServers
|
||||
};
|
||||
|
||||
const pc = new RTCPeerConnection(config);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue