Questions tagged [akka-http]

1

votes
1

answer
463

Views

How to get the current server request timeout in Akka HTTP

Akka HTTP allows request timeouts to be set from either the global setting in application.conf or modified on a per-route basis with directives. How can we get the request timeout for the current request and route? Something like withRequestTimeout(FiniteDuration(5, TimeUnit.SECONDS)) { extractReque...
kag0
1

votes
0

answer
63

Views

Scala alpaakka s3 connect with DO Spaces multipart upload result 403

i am trying to setup akka-http file upload to Digital Ocean Spaces. And i have got problem with multipart upload. I use alpaakka to stream file directly to s3. However i get 403 error SignatureDoesNotMatch on upload. But if i try to upload same file with simple one part upload everything works fine...
Anton M.
1

votes
0

answer
67

Views

Cannot configure the Akka Http server when using the akka-http-spring-boot library

I am trying to setup a project that runs REST services on top of a AKKA HTTP server yet managed by Spring boot. Now i found this project on gihub as a reference and am using that as libraries to achieve my goal. This is the project : https://github.com/scalaspring/akka-http-spring-boot Now i cannot...
Som Bhattacharyya
1

votes
0

answer
119

Views

how can i write the test cases for file Uploading through extractRequestContext in akka http services

Pls suggest here I have an upload service in Akka HTTP micro service it's working fine. now I need to write the test cases for below code path( 'file-upload') { extractClientIP { ip => optionalHeaderValueByName(Constants.AUTH) { auth => (post & extractRequestContext) { request => extractRequ...
Sekhar
1

votes
1

answer
79

Views

How does one provide an unmarshaller for a Scala trait in Akka HTTP?

I am using Akka HTTP and spray-json. I have the following model hierarchy defined: trait Animal { def weight: Int def name: String } case class Dog( weight: Int, name: String //other specific attributes ) extends Animal case class Cat( weight: Int, name: String //other specific attributes ) extends...
oblivion
1

votes
0

answer
337

Views

Akka HTTP: the requested resource could not be found

I'm using the Akka HTTP 'Minimal Example' for my first steps in Akka HTTP. private Route createRoute() { return route( path('hello', () -> get(() -> complete('Say hello to akka-http')))); } Now I want to add a route to my resources/web/test.html, similar to an example on the 'Directives' page: priva...
Thane
1

votes
0

answer
328

Views

Akka streams Source.actorRef vs Source.queue vs buffer, which one to use?

I am using akka-streams-kafka to created a stream consumer from a kafka topic. Using broadcast to serve events from kafka topic to web socket clients. I have found following three approaches to create a stream Source. Question: My goal is to serve hundreds/thousands of websocket clients (some of w...
Vms
1

votes
1

answer
129

Views

Test a connection failure during a route test using ScalaTest and Akka HTTP?

I have a route that takes an id, looks for that id in the database, and then updates the row if the id exists: pathPrefix('rules') { path(JavaUUID) { inputId => put { onComplete(Database.findById(inputId)) { case Success(Some(row)) => complete { Database.update(row.copy(test = true)) .map { _ => Sta...
Donal Tuohy
1

votes
0

answer
100

Views

How can I make an entity as in my case toStrict?

how to use the toStrict for the exception is Substream Source cannot be materialized more than once and here is my source val fileUploadRote = { (post & extractRequestContext & entity(as[String])) { (request, textReq) => extractRequestContext { formFieldMultiMap { fields => println('There are ' + s'...
sekhar
1

votes
1

answer
56

Views

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

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[...
lex82
1

votes
0

answer
37

Views

Superpool vs CahedConnectionPool in akka

I read about super pool in akka documentation. I am fairly new to Akka. Please help me understand how does superPool work in case I want to specify different connection pool settings for different hosts but send request to all using superpool. Would it take that configuration in consideration?
mits
1

votes
0

answer
97

Views

How to get WebSocket close code from Akka HTTP?

We are using Akka HTTP to handle our web socket connections using the akka streams API. We are using a Flow that pipes the incoming messages to a 'connection actor'. A snippet of the code is below: val connection = system.actorOf(ConnectionActor.props()) val in = Flow[Message] .to(Sink.actorRef[Mess...
1

votes
0

answer
68

Views

How to save a websocket client's connection and send it later with akka-streams and akka-http

I'm trying to follow this part of the akka-http documentation where it talks about handling web socket messages asynchronously What I am trying to do is this: Receive a websocket request for a client Serve a payment invoice back to the client Run a background process that has the client's websocke...
Chris Stewart
1

votes
1

answer
94

Views

Any way to reuse a Source[ByteString, Any] (without keeping it all in memory)

Is there any way to make a Source reusable? I have an akka-http server that receives a large file upload and then streams the (chunked) data to subscriber websockets and other HTTP servers via HTTP POST. In both cases, there is an API that accepts a Source[ByteString, Any]: HttpEntity(..., source) i...
Allan
1

votes
1

answer
299

Views

Handle SIGTERM in akka-http

The current (10.1.3) Akka HTTP docs: https://doc.akka.io/docs/akka-http/current/server-side/graceful-termination.html talk about graceful termination, using this code sample: import akka.actor.ActorSystem import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Route import ak...
Rory
1

votes
0

answer
58

Views

Websocket client does not receive data from Akka streams Source.queue

I am using Akka stream Source.queue as Source for websocket clients. Reading from kafka topic with 10k records using kaka consumer API and offering it to Source.queue with buffer 100k. I am using BroardcastHub for fan-out. The websocket client does not get any data but see records from kafka enqueue...
Vms
1

votes
1

answer
41

Views

Why does Akka HTTP default to as little diagnostic informaiton as possible?

More of a philosophical question I am building a new HTTP service with Akka HTTP in Java and in my unit test I get back java.lang.AssertionError: Unexpected status code! Expected :200 OK Actual :400 Bad Request at akka.http.javadsl.testkit.JUnitRouteTestBase$$anon$1.reportDetails(JUnitRouteTest.sc...
Eric Kolotyluk
1

votes
1

answer
177

Views

'term akka.stream' is missing from the classpath when using with Akka Http Spray Json for SprayJsonSupport

I'm using akka-http and reactivemongo in my project and marshalling/unmarshalling case classes with akka-http-spray-json. Here are their dependencies - 'com.typesafe.akka' %% 'akka-http' % '10.1.3' 'com.typesafe.akka' %% 'akka-stream' % '2.5.14' 'com.typesafe.akka' %% 'akka-http-spray-json' % '10.1...
Ishan
1

votes
1

answer
75

Views

Websocket with Graph DSL

I am trying to implement a Websocket Login flow with Akka Flow. I get a myriad of nasty runtime exceptions around Inlets, Outlets and Connection issues. My latest is: java.lang.IllegalStateException: Illegal GraphDSL usage. Inlets [Map.in] were not returned in the resulting shape and not connected....
abergmeier
1

votes
1

answer
201

Views

Loading static html files using Akka-http Java

I've been struggling to get a static file to load from a simple aka-http Java server. I've tried a number of options, but I always get the following error: [ERROR] [09/07/2018 11:52:06.258] [AkkaRestApiApp-akka.actor.default-dispatcher-4] [akka.actor.ActorSystemImpl(AkkaRestApiApp)] Error during pro...
bemorris
1

votes
1

answer
83

Views

A Basic Akka Http Routing question: reconciling signatures

The following code exemplifies a common pattern in Akka http routing: lazy val routes:Route {... pathPrefix('aPath') path(Remaining) { dirName => get { onComplete(aFuture(dirName)) { case Success(res) => handleResult(res) ... My question concerns the final 2 lines of this code. How is the sign...
Ben Weaver
1

votes
0

answer
90

Views

Akka-grpc: how to authenticate request?

Is there a way to intercept request in akka-grpc? (I need to get authentication info and enrich request with it).
Teimuraz
1

votes
1

answer
617

Views

Gradle Error: Project with path ''could not be found in root project ''

Check out the link for the project structure image. RootModule --- ChildModule1 --- ChildModule2 --- ChildModule3 ChildModule3 depends on ChildModule2 depends on ChildModule1 Each settings.gradle defines include ':PreviousModule' project(':PreviousModule').projectDir = new File(settingsDir, '../Pre...
Antriksh Parmar
1

votes
1

answer
87

Views

Error when loading static content using AKKA-HTTP Java

I'm trying out AKKA-Http in Java for the first time(akka-http_2.12 v 10.1.5, akka-stream_2.12 v 2.5.17), but can't seem to load static content for swagger UI. I've added the routes below and able to reach the json and yaml swagger endpoints via http://localhost:8080/api-docs/swagger.json and http://...
Chinedu Ekwunife
1

votes
1

answer
36

Views

Implementing basic S3 compatible API with akka-http

I'm trying to implement the file storage ыукмшсу with basic S3 compatible API using akka-http. I use s3 java sdk to test my service API and got the problem with the putObject(...) method. I can't consume file properly on my akka-http backend. I wrote simple route for the test purposes: def p...
arussinov
1

votes
2

answer
76

Views

Akka Http Test Gzip Response

So, I have a set of Akka Http routes written in scala. Which looks like this val route: Route = { handleRejections(PrimaryRejectionHandler.handler) { handleExceptions(PrimaryExceptionHandler.handler) { cors() { encodeResponseWith(Gzip) { pathPrefix('v1') { new v1Routes().handler } ~ path('ping') { c...
Debdutto Chakraborty
1

votes
0

answer
77

Views

Akka-Http, Server Sent Event and Akka Stream Source : Connection get “Reset” / Stream Source get closed after last page get stopped or refreshed

I’m trying to do some web application using the “Server Sent Event” feature of Akka HTTP. TL;DR : I can run and consume SSE from the browser, but if I have only one page and I refresh it or quit it and reload the page, the SSE entrypoint looks not working anymore as the whole Akka Stream on th...
Totetmatt
1

votes
0

answer
32

Views

Akka-http-testkit returns nested list instead of flattened one

I'm using akka-http-testkit for testing routes and scalamock for mocking my class. The endpoint is a GET with a payload. I'v got a method which return Future[List[Map[String, Any]]] - basically raw rows from the DB. It works ok with curl, but my assertion fails on comparing JSON because it has [[ an...
fr3ak
1

votes
1

answer
76

Views

How to call a POST to another service and receive json data

I have two Akka HTTP services (Service 1 and Service 2). One needs to communicate with the other. Service 2 provides a POST endpoint /lastname that takes in json payload like this {name: 'doe'} and returns {'returnVal':false} or {'returnVal':true} Question How can Service 1 connect to it, send json...
Anthony
1

votes
2

answer
137

Views

How to match String using pathPrefix/rawPathPrefix in Akka HTTP?

This works: rawPathPrefix('Ad(' ~ LongNumber ~ ')') { id => id is now a Long, but this doesn't work: rawPathPrefix('Ad(' ~ String ~ ')') { id => id is now a RequestContext, not a String?
Rory
1

votes
1

answer
47

Views

Failures in streaming handling of requests - what happens to connection?

The documentation for akka-http explains that it is important to consume a request stream entirely since bytes that are not pulled will be interpreted as backpressure (https://doc.akka.io/docs/akka-http/current/implications-of-streaming-http-entity.html). When you know beforehand that the stream can...
medtechguy
1

votes
0

answer
66

Views

Handling exceptions in akka-stream in akka-http complete function call

I'm having issues with akka-http returning an exception when a akka-stream fails while being run in a akka-http complete method. Working when running the stream before akka-http returns result. Would like to stream the result even if the stream fails. Have build a scala akka-http webserver with akk...
Mads Fox
1

votes
1

answer
54

Views

How to make parallel Http request using Akka-Http?

I am new to Scala and trying to implement a library where I will get thousands of URLs. My job is to download the content from those URLs. I would have opted for simple scalaj-http library but it does not serve my purpose. The code I came with is this: class ProxyHttpClient { def get(url: String, p...
alok
1

votes
0

answer
29

Views

akka-http how to make browser generate authentication window?

I have Server.Route. I wanna get authentication window in browser, that asks user to type login and password. I read in article that Server should return 401 error and authentication header to Client to make browser generate this window. val route = path('somepath') { get { respondWithHeaders(RawHea...
Valeriya
1

votes
1

answer
39

Views

Unable to unmarshal LocalDate and LocalTime class using Jackson

I'm making a POST route using akka, where I'm deserializing my Json data into Video object, but the following curl request: curl -H 'Content-Type: application/json' -X POST -d '{'title': 'Video Title','videoDate':'10-2-2018','videoTime':'12:10:11'}' http://localhost:9090/updatedData gives an error:...
Yatharth7
0

votes
0

answer
4

Views

Akka-http WebSocket how to continusly send messages from MQTT topic

I want to create a WebSocket server, waiting for MQTT topic from the client and send continuously topics messages to the client. Here is what I've done in Scala def echoService(): Flow[Message, Message, _] = Flow[Message].map{ case TextMessage.Strict(txt) => val temp = password.split('/') if (temp.n...
1

votes
1

answer
21

Views

How to broadcast the received messages to two different flows

How to broadcast the received messages to two different flows I am using akka stream websocket client to request and receive the data websocket server. With the received data from the websocket, I would like to broadcast into two different flows. The image below, should clarify the scenario: A...
zero_coding
1

votes
1

answer
1.3k

Views

Multi-part form data upload with Akka HTTP

I'm trying to figure out how to create a multi-part form data request with Akka HTTP (client API) but I can't find a way to express form data. Does anyone know how to create form data that would take a file or input stream?
MaatDeamon
1

votes
1

answer
521

Views

Akka HTTP ambiguous implicit conversion

I'm cutting my teeth on Akka HTTP by working this example. For the purposes of learning, I converted it to a Maven project. However, I'm getting compilation errors as follows using Akka v2.3.12 and Akka Stream v1.0. The POST DSL fails with similar errors that I'm not posting for brevity. How can I g...
Abhijit Sarkar
1

votes
1

answer
156

Views

mapInnerRoute is not working

I'm trying to create route that would wrap caught exception into my exception that carries user object of logged-in user. Ideally I prefer to put that information into ContextRequest in order to use it in my ExceptionHandler but it's immutable. I concluded that the right way to do it is to use mapIn...
expert

View additional questions