0

we use sdn4 to access neo4j,but sometimes this exception occurs. what's the reason? neo4j's version 2.2.5。what config we can config to avoid this exception?

  at org.neo4j.ogm.session.request.DefaultRequest.execute(DefaultRequest.java:105) ~[neo4j-ogm-1.1.4-20151201.162656-1.jar:na]
at org.neo4j.ogm.session.request.SessionRequestHandler.execute(SessionRequestHandler.java:99) ~[neo4j-ogm-1.1.4-20151201.162656-1.jar:na]
at org.neo4j.ogm.session.request.SessionRequestHandler.execute(SessionRequestHandler.java:64) ~[neo4j-ogm-1.1.4-20151201.162656-1.jar:na]
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery$1.apply(QueryResultGraphRepositoryQuery.java:65) ~[spring-data-neo4j-4.0.0.RELEASE.jar:na]
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery$1.apply(QueryResultGraphRepositoryQuery.java:62) ~[spring-data-neo4j-4.0.0.RELEASE.jar:na]
at org.neo4j.ogm.session.delegates.TransactionsDelegate.doInTransaction(TransactionsDelegate.java:54) ~[neo4j-ogm-1.1.4-20151201.162656-1.jar:na]
at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:422) ~[neo4j-ogm-1.1.4-20151201.162656-1.jar:na]
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery.mapToConcreteType(QueryResultGraphRepositoryQuery.java:62) ~[spring-data-neo4j-4.0.0.RELEASE.jar:na]
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery.execute(QueryResultGraphRepositoryQuery.java:52) ~[spring-data-neo4j-4.0.0.RELEASE.jar:na]
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:50) ~[spring-data-neo4j-4.0.0.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:454) ~[spring-data-commons-1.11.0.RELEASE.jar:na]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:432) ~[spring-data-commons-1.11.0.RELEASE.jar:na]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
Caused by: org.apache.http.NoHttpResponseException: 10.171.23.230:7475 failed to respond
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:143) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261) ~[httpcore-4.4.1.jar:4.4.1]
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165) ~[httpcore-4.4.1.jar:4.4.1]
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272) ~[httpcore-4.4.1.jar:4.4.1]
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124) ~[httpcore-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[httpclient-4.4.1.jar:4.4.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) ~[httpclient-4.4.1.jar:4.4.1]
at org.neo4j.ogm.session.request.DefaultRequest.execute(DefaultRequest.java:80) ~[neo4j-ogm-1.1.4-20151201.162656-1.jar:na]
... 56 common frames omitted
Beni
  • 51
  • 3

2 Answers2

1

It is possible the server has closed the connection due to a long period of inactivity. The Apache HttpClient documentation states this:

2.6. Connection keep alive strategy The HTTP specification does not specify how long a persistent connection may be and should be kept alive. Some HTTP servers use a non-standard Keep-Alive header to communicate to the client the period of time in seconds they intend to keep the connection alive on the server side. HttpClient makes use of this information if available. If the Keep-Alive header is not present in the response, HttpClient assumes the connection can be kept alive indefinitely. However, many HTTP servers in general use are configured to drop persistent connections after a certain period of inactivity in order to conserve system resources, quite often without informing the client

Normally, re-using a stale connection would be detected, but this answer suggests that under some circumstances a write request on a stale connection can appear to succeed. In this case the lack of a valid response will give rise to the org.apache.http.NoHttpResponseException

SDN does not currently have any mechanism to mitigate against this problem, and I'm not aware of any settings in neo4j-server.properties to prevent this behaviour on the server side.

Community
  • 1
  • 1
Vince
  • 2,181
  • 13
  • 16
0

The latest snapshot version of the OGM, 1.1.5-SNAPSHOT has a request retry strategy enabled in the event that a NoHttpResponseException is thrown: https://github.com/neo4j/neo4j-ogm

The retry strategy is configured to attempt the request 3 more times after the initial failure, with a delay of 2 seconds between each attempt.

The rationale for this strategy is based on the Apache HttpClient documentation which states the following:

In some circumstances, usually when under heavy load, the web server may be able to receive requests but unable to process them. A lack of sufficient resources like worker threads is a good example. This may cause the server to drop the connection to the client without giving any response. HttpClient throws NoHttpResponseException when it encounters such a condition. In most cases it is safe to retry a method that failed with NoHttpResponseException. http://hc.apache.org/httpclient-3.x/exception-handling.html

The 1.1.5-SNAPSHOT version of the OGM is compatible with SDN 4.0.

OGM users

If you're using the OGM "standalone", you'll need to add this dependency to your pom:

<repository>
    <id>neo4j-snapshots</id>
    <url>http://m2.neo4j.org/content/repositories/snapshots</url>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

SDN users

The required dependency should already be included in the latest Spring Data Neo4j 4.0.0-SNAPSHOT build. You'll need the following repository in your pom to use the snapshot build of SDN 4.0

<repository>
    <id>spring-libs-snapshot</id>
    <url>http://repo.spring.io/libs-snapshot</url>
</repository>
Vince
  • 2,181
  • 13
  • 16