Description
Java clients that connect to the ActiveMQ broker over the HTTP transport connector loose the conection after 30 seconds with the following exception:
WARN | Transport (http://localhost:8866) failed , attempting to automatically reconnect: {} java.io.IOException: Failed to perform GET on: http://localhost:8866 Reason: Read timed out at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:34) at org.apache.activemq.transport.http.HttpClientTransport.run(HttpClientTransport.java:208) at java.lang.Thread.run(Thread.java:748) Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) at java.net.SocketInputStream.read(SocketInputStream.java:171) at java.net.SocketInputStream.read(SocketInputStream.java:141) at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:158) at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82) at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:271) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138) at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56) at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259) at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281) at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:257) at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:207) at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273) at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125) at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:684) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:486) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at org.apache.activemq.transport.http.HttpClientTransport.run(HttpClientTransport.java:180) ... 1 more
This happens on the default 5.15.3 distribution on Windows and on Ubuntu with the following transport connector:
<transportConnector name="http" uri="http://0.0.0.0:8866?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
There are no errors in the borker log that could explain the problem.
This is the sample program that I used:
import javax.jms.Connection; import javax.jms.JMSException; import org.apache.activemq.ActiveMQConnectionFactory; public class TestConnect { public static void main(String[] args) throws JMSException { System.out.println("Connecting:"); ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover:(http://localhost:8866)?randomize=false&jms.prefetchPolicy.queuePrefetch=1"); Connection connection = connectionFactory.createConnection("admin", "admin"); connection.start(); } }
NOTE:
In the meantime I found the cause for the problem. A default socket timeout of 30 secods for the HTTP client was introduced with the following ticket: https://issues.apache.org/jira/browse/AMQ-6397
This timeout somewhow seems to conflict with the keep alive requests that stays open for arround 30 seconds. I increased the default timeout to 90 seconds and this seems to resolve the problem (see attached version of HttpClientTransport.java).
Attachments
Attachments
Issue Links
- links to