Akka Http non-responsive - scala

I had a responsive Akka Http app, did some changes, then got these messages:
14:55:56.128 INFO bootstrap.akka.HttpActor - Accepted new connection from /127.0.0.1:55192
14:56:23.938 INFO bootstrap.akka.HttpActor - Accepted new connection from /127.0.0.1:55193
14:56:26.684 ERROR akka.actor.ActorSystemImpl - Internal server error, sending 500 response
akka.stream.impl.io.TcpStreamActor$$anonfun$handleSubscriptionTimeout$1$$anon$1: Publisher was not attached to upstream within deadline (5000) ms
14:56:26.684 ERROR akka.actor.ActorSystemImpl - Internal server error, sending 500 response
akka.stream.impl.io.TcpStreamActor$$anonfun$handleSubscriptionTimeout$1$$anon$1: Publisher was not attached to upstream within deadline (5000) ms
I cannot figure out what they mean. They are not mentioned in the docs and no Google hits. Could anyone share some insight?
akka.version=2.3.12
akka.stream.version=1.0
scala.version=2.11.6
jdk.version=1.8.0_60

Related

REST API slow response on production server

I have a spring-boot application that uses Java on the backend and react.js on the frontend side. Some API calls are too slow in the production environment (it takes 1 min in the production environment and 4 ms in the local). The slow APIs are not fetching any large data set. I was trying to debug the code and found Nginx error logs. The logs are as follows:
[error] 29755#29755: *632803 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.XX.X.XX, server: test.apps.com, request: "GET /apiv1/master/modules?&isglobal=all&startIndex=0&pageSize=10&sortBy=id HTTP/1.1", upstream: "https://172.XX.X.XX:443/mhk-cmt-app/master/modules?&isglobal=all&startIndex=0&pageSize=10&sortBy=id", host: "test.apps.com", referrer: "https://test.apps.com/admin/app-setting"
How can I improve the API response time in production?

HTTP status code for failed serialization

I have a GET /v2/developer/jhUxad8 endpoint which get developer from database and serialize it to json.
What http status code should I return when serialization fail?
https://www.codetinkerer.com/2015/12/04/choosing-an-http-status-code.html
What http status code should I return when serialization fail?
If I'm understanding you correctly, the server understands the request, and is trying to fulfill it, but because of a data problem is unable to do so.
500 Internal Server Error
The 500 (Internal Server Error) status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

Spray.can.server.request-timeout property has no effect

In my src/main/resources/application.conf I include:
spray.can.server {
request-timeout = 1s
}
In order to test this, in the Future which is servicing my request I put a Thread.sleep(10000).
When I issue a request, the server waits 10 seconds and responds with no hint of a timeout being sent to the client.
I am not overriding the timeout handler.
Why are my clients (chrome and curl) not receiving a timeout?
The configuration looks correct, so Spray request timeout should be working. One of the frequent reasons for it not working is that your config application.conf is not being used by the application.
The reasons for config being ignored could be that it's in the wrong place, not included in your classpath, or not included in a JAR that you package.
To troubleshoot first check that default Spray timeout is working. By default it's 20 sec. Make your code sleep for 30sec and see if you get timeouts triggered.
Check what's in your final config values by printing it. Set this in your conf:
akka {
# Log the complete configuration at INFO level when the actor system is started.
# This is useful when you are uncertain of what configuration is used.
log-config-on-start = on
}
Finally, keep in mind other timeouts like timeout-timeout = 2 s.
I think the request-timeout is for the http client, if the response is not returned before that value, the client will get a timeout from spray, see the spary doc
# If a request hasn't been responded to after the time period set here
# a `spray.http.Timedout` message will be sent to the timeout handler.
# Set to `infinite` to completely disable request timeouts.
For example, in my web browser, I can got a below message:
Ooops! The server was not able to produce a timely response to your request.
Please try again in a short while!
If the timeout is long enough, the browser will keep waiting until a response is returned

Connection reset by tomcat server on continuous reception of HTTP GET request

I am doing load test of web server. Current i am using tomcat 6 to test my code. While running the server resets the connection after few minutes on receiving continuous GET requests for the same page. If I send GET request with some gap (say 500 ms) then it works fine. If I send GET request with 10 ms or less than 10 ms then server resets the connection after few seconds from the start of test. Please help on how to fix this problem. What is the reason for reset ? Whether the server is overloaded or I have to perform some operation while establish connection ??.
My GET request format is:
GET /index.html HTTP/1.1
Host: 180.168.40.40
Connection: keep-alive

Wget gives up too quickly on a Express API

I want to download the result of a Express.js REST API which is very slow to process (~10 minutes). I tried few timeout options with wget but it gives up after few minutes while I ask it to wait around ~60 000 years.
wget "http://localhost:5000/slowstuff" --http-user=user --http-password=password --read-timeout=1808080878708 --tries=1
--2015-02-26 11:14:21-- http://localhost:5000/slowstuff
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5000... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authentication selected: Basic realm="Authorization Required"
Reusing existing connection to [localhost]:5000.
HTTP request sent, awaiting response... No data received.
Giving up.
EDIT:
The problem doesn't come from the wget timeout value. With a timeout set to 4 seconds, the error is different: Read error (Connection timed out) in headers. And I have exactly the same problem with curl.
I think the problem comes from my API. It looks like a timeout of 2 minutes is set by default in NodeJS.
Now, I need to find how to change this value.
This
--http-password=password--read-timeout=1808080878708
is missing a blank. Use
--http-password=password --read-timeout=1808080878708