Сервер janus websocket возвращает 403, запущенный через docker - PullRequest
0 голосов
/ 06 августа 2020

Я использую сервер janus через docker

https://github.com/linagora/docker-janus-gateway

его веб-сервер доступен по адресу 8188, а его возвращающий 403 при выдаче Запрос GET на http://0.0.0.0: 8188 / janus / info

вот как я запускаю контейнер DOCKER_IP = 127.0.0.1 docker run -p 80:80 -p 7088: 7088 -p 8088: 8088 -p 8188: 8188 -p 10000-10200: 10000-10200 / udp linagora / janus-gateway

и вот мой код, который возвращает «закрыть», я использую поддержку веб-сокетов на стороне клиента

https://doc.akka.io/docs/akka-http/current/client-side/websocket-support.html

Я использую akka http в Scala

object JanusSessionDemo {

  def main(args: Array[String]): Unit = {
    implicit val system = ActorSystem()
    implicit val materializer = ActorMaterializer()
    import system.dispatcher

    // print each incoming strict text message
    val printSink: Sink[Message, Future[Done]] =
      Sink.foreach {
        case message: TextMessage.Strict =>
          println(message.text)
      }

    val helloSource: Source[Message, NotUsed] =
      Source.empty

    //Source.single(TextMessage("hello world!"))

    // the Future[Done] is the materialized value of Sink.foreach
    // and it is completed when the stream completes
    val flow: Flow[Message, Message, Future[Done]] =
    Flow.fromSinkAndSourceMat(printSink, helloSource)(Keep.left)

    // upgradeResponse is a Future[WebSocketUpgradeResponse] that
    // completes or fails when the connection succeeds or fails
    // and closed is a Future[Done] representing the stream completion from above

 
    val (upgradeResponse, closed) =
      Http().singleWebSocketRequest(WebSocketRequest("ws://0.0.0.0:8188"), flow)


    val connected = upgradeResponse.map { upgrade =>
      // just like a regular http request we can access response status which is available via upgrade.response.status
      // status code 101 (Switching Protocols) indicates that server support WebSockets
      if (upgrade.response.status == StatusCodes.SwitchingProtocols) {
        println("Done")
        Done
      }
      else if (upgrade.response.status == StatusCodes.OK) {
        println("Ok")
      }
      else {
        throw new RuntimeException(s"Connection failed: ${upgrade.response.status}")
      }
    }

    // in a real application you would not side effect here
    // and handle errors more carefully
    connected.onComplete(println)
    closed.foreach(_ => println("closed"))
  }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...