We are getting connection closed error from server and want to gracefully close connection on our client end, i want to set keep-alive timeout on our end, but is there a way i can know keep-alive value on server end ? ( any curl flag) so i can set my keep-alive value lower than server value.
Related
This is a SpringBoot website. When I debug it in Chrome, I find that there is Keep-Alive: timeout=38 in the response header.
I guess it means the max idle time a TCP connection can hold. This is from here
timeout: indicating the minimum amount of time an idle connection has to be kept opened (in seconds). Note that timeouts longer than the TCP timeout may be ignored if no keep-alive TCP message is set at the transport level.
Question 1: How to change the default value in SpringBoot? I update the appllicaiton.property and set server.connection-timeout=1200000000, no affect.
Question 2: If the browser side does not contain "Proxy-Connection: keep-alive" in the header, which means that it will not reuse the TCP connection. Now, if a TCP connection works for more than 38s because the content is too much to transfer from the browser to server, will it be closed by the server?
Edit: This morning when I debug Chrome for the same website, the keep-alive in response header is gone. That is werid. Why is it not there all the time?
I'm unable to get my application utilizing web sockets to work.
I have a site www.example.com which uses an anti-DDoS service so it resolves to IP X.X.X.X. The real address of the server is Y.Y.Y.Y. The anti-DDoS service does not proxy web sockets traffic so I wanted to stream it directly to the real address (it's difficult to find it for attack in reality so this will work) so what I did is instead of pointing it to ws://www.example.com:100/, I pointed it to ws://Y.Y.Y.Y:100/.
Now if I access my application by the real IP (http://Y.Y.Y.Y), it connects to ws://Y.Y.Y.Y:100/ just fine but if I use http://www.example.com link (which resolves to X.X.X.X), ws://Y.Y.Y.Y:100/ won't connect saying "WebSocket connection to 'ws://Y.Y.Y.Y:100/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED".
I guess this has something to do with security but I don't know what exactly. Please help.
Maybe the websocket server sees the domain in Origin HTTP header different than the domain in the Host HTTP header and it is refusing the connection because of that. The Origin header is usually used to figure out if the connection is coming from an allowed website, since websockets are not under the Same Origin Policy.
The request that works will look like this:
GET / HTTP/1.1
Host: YYYY
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Version: 13
Origin: http://YYYY
The request that is refused will look like this:
GET / HTTP/1.1
Host: YYYY
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Version: 13
Origin: http://www.example.com
It is hard to tell with this little information. Don't you get any error in the server logs?
I am configuring ELB with EC2 in AWS and run into "Instance has failed at least the UnhealthyThreshold number of health checks consecutively" error to cause the instance out of service. I have checked,
1) as I m using 8080 for security check port and my path is "/index.html". I test the link http://ec2DNSname:8080/index.html in the browser, it returns,
Response header:
HTTP/1.1 200 OK
X-Powered-By: Express
Accept-Ranges: bytes
ETag: "150-1420697739000"
Date: Thu, 08 Jan 2015 06:16:21 GMT
Cache-Control: public, max-age=0
Last-Modified: Thu, 08 Jan 2015 06:15:39 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 150
Vary: Accept-Encoding
Connection: keep-alive
2) In my EC2 config, I allow the the inbound TCP traffic on 8080 from any machines
Any other possible cause of failing the health check?
Thanks
Hammer
As long as the page returns a 200 response, it should eventually pass the health check. The Health Check configuration includes the number of times a Health Check needs to return a good result and how often to check it. So, a Healthy count of 5 with a check every 30 seconds would take 2.5 minutes to return as Healthy.
If the HTTP health check is failing, try it with a TCP health check on port 8080.
Also, just in case, check that your VPC configuration allows a connection from the Load Balancer to the EC2 instance. This will be automatic if they are in the same Subnet, but Network ACLs can impact a connection between different Subnets.
if u create a linux server then you only need to attache one index.html file to your server,then it will work with http as well as TCP.
please let me it works or not. or you check Troubleshoot a Classic Load Balancer: Health Checks (1st error).
I am using activeMQ as a full featured broker. I have deployed my spring application on Tomcat 8.0.8. I am sending very large messages and I do it in separate Thread (about 230000 stomp messages in while loop). When I use Chrome, or Firefox in activeMQ console, I see that messages are being consumed almost instantly. The problem as always is IE. I can see that it stops to consume messages (after about 1000), and Tomcat fails at
java.lang.Thread.run(Thread.java:722) aused by: org.apache.catalina.connector.ClientAbortException: java.io.IOExcepti n: An existing connection was forcibly closed by the remote host at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffe .java:396) at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:426) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java: 42) at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:31 ) etc....
Is IE such slow a consumer by default or what? I have tried with numerous slow consumer politic with ActiveMQ but without success.
The exception points to an IO error of some sort on the client side. You can try to track what happens on the client side, e.g. use Fiddler to check for any reported errors, or if that fails Wireshark to track what HTTP messages are sent out and how far it gets. Also try using the latest 4.0.6.BUILD-SNAPSHOT (or better yet 4.1.0.BUILD-SNAPSHOT) available from repo.spring.io/libs-snapshot. There are some recent SockJS related fixes worth trying out.
I have tried with 4.1.0.BUILD-SNAPSHOT, but with no success. After a while Fiddler reports:
POST mylink/ami-0.1.0/liveEvents/072/omseen4z/xhr_send?t=1404832405318 HTTP/1.1
Accept: /
Accept-Language: en-us
Referer: mylink/ami-0.1.0/liveEvents/iframe.html#ensha4ej
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Host: mylink
Content-Length: 6
DNT: 1
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=4CC71475E3FF1377C79D77C349710237; theme=standard
["\n"]
and HTTP/1.1 404 Not Found error occurs.
What can be the reason of this(new line message). I have added activemq prefetchSize of 1 and I do ack on every received message.
Marko
A few weeks ago I wrote a small program which created a socket to an apache webserver and made a request.
Back then I did not know that this web server had a KeepAliveTimeout of 5 seconds.
After my first request I waited 1 minute. After this I wanted to reuse my first socket for another webserver request, but got an error.
From Beej's Guide to Network Programming I learned that if recv returns 0, then the other side has closed its connection:
Wait! recv() can return 0. This can mean only one thing: the remote side has closed
the connection on you! A return value of 0 is recv()'s way of letting you know this
has occurred.
My questions are now:
What does Apache send when the KeepAliveTimeout is over - a FIN or a RST packet?
I know that using a TCP connection for 2 unrelated HTTP requests like in this scenario might
not be the best thing. But in order to understand TCP more the next question is:
After my first successful http request, and before sending the next HTTP request over the same socket, would there be somehow a possibility to get informed about this keepalivetimeout TCPsocket termination of the server other than receiving 0 from the next recv() call?
It will send a FIN. If you write a request to the server after that, send() will return -1 with errno/WSAGetLastError() = ECONNRESET.
would there be somehow a possibility to get informed about this keepalivetimeout tcp socket termination of the server
Yes, by reading the proper response header parameter, namely Keep-Alive: timeout=delta-seconds:
'timeout' Parameter
A host sets the value of the timeout parameter to the time that the host will allows an idle connection to remain open before it is closed. A connection is idle if no data is sent or received by a host.
The value of the timeout parameter is a single integer in seconds.
A host MAY keep an idle connection open for longer than the time that it indicates, but it SHOULD attempt to retain a connection for at least as long as indicated.
As you can see, it's up to the host to decide. Given it only SHOULD try to keep the connection open as long as promised, but it isn't required that it does in order to conform to the spec, so the server might decide to close and reuse the connection to serve another pending client.