akka-http

Consuming both Strict and Streamed WebSocket Messages in Akka

前提是你 提交于 2019-12-11 05:00:47
问题 I am experimenting with building a web socket service using Akka HTTP. I need to handle Strict messages that arrive in totality, as well as handle Streamed messages that arrive in m multiple frames. I am using a route with handleWebSocketMessages() to pass the handling of web sockets off to a flow. The code I have looks something like this: val route: Route = get { handleWebSocketMessages(createFlow()) } def createFlow(): Flow[Message, Message, Any] = Flow[Message] .collect { case TextMessage

Is there an example of how to use akka-http with servlet container?

隐身守侯 提交于 2019-12-10 21:12:11
问题 Right now using spray with Servlet30ConnectorServlet successfully in tomcat and was hoping to find similar example usage with akka-http 回答1: I don't think there is any connector servlet in akka-http yet. You can have a look at the api here: Akka http API 来源: https://stackoverflow.com/questions/29629111/is-there-an-example-of-how-to-use-akka-http-with-servlet-container

What webserver uses akka akka-http and how can I get the version of it?

我是研究僧i 提交于 2019-12-10 16:13:28
问题 I'm using akka and akka-http 2.4.2 and I'm trying ti understand the internal components of them. What does akka and akka-http use to start a rest web-service? It uses an embebedd webservice? (like Jetty?) How do I get the version of it? The code I run to start my rest web-service is: implicit val actorSystem = ActorSystem("system") implicit val actorMaterializer = ActorMaterializer() val route: Route = { blablabla ... } val bind = Http().bindAndHandle(route, "0.0.0.0", 8080) Thanks. 回答1:

Akka-Http 2.4.9 throws java.lang.NoClassDefFoundError: akka/actor/ActorRefFactory exception

自古美人都是妖i 提交于 2019-12-10 16:02:02
问题 I am trying to build a simple web service with Akka-http. I followed this guide: http://doc.akka.io/docs/akka/2.4.9/scala/http/low-level-server-side-api.html and everything works fine, when I run sbt run. When I execute java -jar PROJECT.jar it returns: Exception in thread "main" java.lang.NoClassDefFoundError: akka/actor/ActorRefFactory at WebServer.main(WebServer.scala) Caused by: java.lang.ClassNotFoundException: akka.actor.ActorRefFactory at java.net.URLClassLoader.findClass

Akka Streams / HTTP: Get original request from response

家住魔仙堡 提交于 2019-12-10 11:16:08
问题 I have an Akka Streams source that goes through a flow and posts an HTTP request: source.map(toRequest) .via(Http().outgoingConnection(host)) .map(toMessage) Suppose that the toRequest method maps a string to an HttpRequest , and the toMessage method maps the HttpResponse to a message class that is needed to process downstream. Suppose that the message class needs to contain some of the original information. Is it possible to get the original HttpRequest from the HttpResponse ? If not, is

Waiting for a client websocket flow to connect before connecting source and sink

痴心易碎 提交于 2019-12-08 06:35:43
问题 I'm using akka-streams to set up a client web socket. I'm trying to encapsulate the setup in a method with the following signature: def createConnectedWebSocket(url: String): Flow[Message, Message, _] It is clear how to create the web socket flow but it is not connected yet: val webSocketFlow: Flow[Message, Message, Future[WebSocketUpgradeResponse]] = Http().webSocketClientFlow(WebSocketRequest(url)) I first want to Await the upgrade response future and then return the socket flow. However,

How to send a file as a response using akka http?

感情迁移 提交于 2019-12-08 03:08:19
问题 I am a little new to akka world, so my domain of knowledge is a bit small. I am creating an https server and handling it using akka streams and http, for a specific url, i need to send a file back to client. How can i achieve that using akka streams and avoiding the akka routes. def handleCall(request:HttpRequest):HttpResponse = { logger.info("Request is {}",request) val uri:String = request.getUri().path() if(uri == "/download"){ val f = new File("/1000.txt") logger.info("file download")

How to do akka-http request-level backpressure?

徘徊边缘 提交于 2019-12-07 19:59:04
问题 In akka-http, you can: Set akka.http.server.max-connections, which will prevent more than that number of connections. Exceeding this limit means clients will get connection timeouts. Set akka.http.server.pipelining-limit, which prevents a given connection from having more than this number of requests outstanding at once. Exceeding this means clients will get socket timeouts. These are both forms of backpressure from the http server to the client, but both are very low level, and only

How to run Akka Streams graph on a separate dispatcher with timeout?

做~自己de王妃 提交于 2019-12-07 11:58:48
问题 This question is based on a pet project that I did and this SO thread. Inside a Akka HTTP route definition, I start a long-running process, and naturally I want to do that without blocking the user. I'm able to achieve this with the code snippet below: blocking-io-dispatcher { type = Dispatcher executor = "thread-pool-executor" thread-pool-executor { fixed-pool-size = 16 } throughput = 1 } complete { Try(new URL(url)) match { case scala.util.Success(u) => { val src = Source.fromIterator(() =>

How to clean up akka-http websocket resources following disconnection and then retry?

╄→гoц情女王★ 提交于 2019-12-07 10:47:34
问题 The code below successfully establishes a websocket connection. The websockets server (also akk-http) deliberately closes the connection using Andrew's suggested answer here. The SinkActor below receives a message of type akka.actor.Status.Failure so I know that the flow of messages from Server to Client has been disrupted. My question is ... How should my client reestablish the websocket connection? Has source.via(webSocketFlow).to(sink).run() completed? What is best practice for cleaning up