我在我的ANGLE项目中使用了livekit客户端SDK.如何在生产模式下使用nginx for https和wss?

我使用nginx作为Web服务器,并将所有http流量重定向到HTTPS. 当我使用http甚至HTTPS时,我无法连接到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();
    }
  });

推荐答案

您可以在包含以下内容的环境文件中使用Web服务器URL:

wsUrl: 'yourIP/ws'

并在您的nginx中使用WS名称声明一个位置,并将所有流量重定向到您的Web套接字服务.

Angular相关问答推荐

Ionic 5角形共享两个模块之间的组件

运行容器后,Docker容器立即退出

带逻辑的组件decorator 中的Angular 主机侦听器属性

带有搜索功能的CDK-VIRTUAL-SCROLL-VIEPORT不显示该值

带输入的单位测试Angular 分量.需要

独立Angular 零部件不在辅零部件或共享零部件中工作

属性';apiUrl';在我的Angular 应用程序上不存在类型';{}';错误

ANGLING HTTP.GET()返回包含数据的数组

如何在Primeng中实现自定义排序

一个接一个的Angular http请求,但只关心第一个

当try 关闭浏览器选项卡时显示alert 时,我是否可以捕获用户是否取消警告

angular material日期 Select 器中的日期不正确

缺少 .angular-cli.json 文件:Angular

错误:您要查找的资源已被删除、名称已更改或暂时不可用

如何在angular 5 中获取基本网址?

Angular url加号转换为空格

相对于根目录的 SCSS 导入

Angular:ViewChild 上未定义 nativeElement

如何在 Angular 6 中使用 mouseover 和 mouseout

Angular 6在输入键上添加输入