i’m using livekit client sdk in my angular project. how can i use nginx for https and wss in production mode?
i’m using nginx as a web server and redirect all http traffic to https.
when i use http or even https i can’t connect to websocket.
room
.on(RoomEvent.ParticipantConnected, this.participantConnected.bind(this))
.on(RoomEvent.ParticipantDisconnected, this.participantDisconnected.bind(this))
// .on(RoomEvent.DataReceived, this.handleData.bind(this))
.on(RoomEvent.Disconnected, this.handleRoomDisconnect.bind(this))
.on(RoomEvent.Reconnecting, () => this.appendLog('Reconnecting to room'))
.on(RoomEvent.Reconnected, () => {
this.appendLog('Successfully reconnected. server', room.engine.connectedServerAddress);
})
.on(RoomEvent.AudioPlaybackStatusChanged, () => {
if (room.canPlaybackAudio) {
this.$('start-audio-button')?.setAttribute('disabled', 'true');
} else {
this.$('start-audio-button')?.removeAttribute('disabled');
}
})
.on(RoomEvent.MediaDevicesError, (e: Error) => {
const failure = MediaDeviceFailure.getFailure(e);
this.appendLog('media device failure', failure);
})
.on(RoomEvent.ConnectionQualityChanged,
(quality: ConnectionQuality, participant?: Participant) => {
this.appendLog('connection quality changed', participant?.identity, quality);
},
)
.on(RoomEvent.SignalConnected, async () => {
if (shouldPublish) {
await room.localParticipant.enableCameraAndMicrophone();
this.updateButtonsForPublishState();
}
});
>Solution :
you can use a web server url in environment file with this content:
wsUrl: 'yourIP/ws'
and in your nginx declare a location with ws name and redirect all traffic to your web socket service.