0
我想嘗試下面的小例子從遠程主機傳入連接:阿卡HTTP不允許在MacOS
object Webserver {
def main(args: Array[String]) {
implicit val system = ActorSystem("my-system")
implicit val materializer = ActorMaterializer()
// needed for the future flatMap/onComplete in the end
implicit val executionContext = system.dispatcher
val route =
path("hello") {
get {
redirect(Uri("https://google.com"), StatusCodes.PermanentRedirect)
}
}
val bindingFuture = Http().bindAndHandle(route, "localhost", 8080)
println(s"Server online at http://localhost:8080/\nPress RETURN to stop...")
StdIn.readLine() // let it run until user presses return
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
.onComplete(_ => system.terminate()) // and shutdown when done
}
}
從在MacOS同一主機訪問時,這完美的作品。但是,當我遠程訪問主機時,我無法訪問akka網絡服務器。
我檢查了我的防火牆選項,並驗證了程序java
允許傳入連接。
一個更可疑的事情:當我運行python -m SimpleHTTPServer 8080
,我得到如下窗口:
開始我的阿卡應用程序時,我沒有得到這個窗口。我是否必須實現自定義邏輯來徵求權限或什麼?
這樣做的竅門!非常感謝 –