2012-11-22 162 views
2

我操作API服務器。
當移動APP與API服務器聯繫時,有時會發生該異常。
我試過在測試服務器上測試,但我無法重現。 (我改變了Apache和Tomcat的連接時間。)

HttpMessageNotReadableException:無法讀取JSON:讀取超時

有什麼問題?
我該如何解決這個問題?


ERROR Could not read JSON: Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out 
org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out 
     at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:125) 
     at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:153) 
     at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:120) 
     at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:91) 
     at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:71) 
     at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:75) 
     at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:156) 
     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:117) 
     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) 
     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) 
     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) 
     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) 
     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) 
     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) 
     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) 
     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) 
     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
     at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) 
     at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291) 
     at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776) 
     at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705) 
     at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898) 
     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) 
     at java.lang.Thread.run(Thread.java:662) 
Caused by: java.net.SocketTimeoutException: Read timed out 
     at java.net.SocketInputStream.socketRead0(Native Method) 
     at java.net.SocketInputStream.read(SocketInputStream.java:129) 
     at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) 
     at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) 
     at java.io.BufferedInputStream.read(BufferedInputStream.java:317) 
     at org.apache.jk.common.ChannelSocket.read(ChannelSocket.java:628) 
     at org.apache.jk.common.ChannelSocket.receive(ChannelSocket.java:566) 
     at org.apache.jk.common.JkInputStream.receive(JkInputStream.java:200) 
     at org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:179) 
     at org.apache.coyote.Request.doRead(Request.java:427) 
     at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:304) 
     at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:419) 
     at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:327) 
     at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193) 
     at org.codehaus.jackson.impl.ByteSourceBootstrapper.ensureLoaded(ByteSourceBootstrapper.java:507) 
     at org.codehaus.jackson.impl.ByteSourceBootstrapper.detectEncoding(ByteSourceBootstrapper.java:129) 
     at org.codehaus.jackson.impl.ByteSourceBootstrapper.constructParser(ByteSourceBootstrapper.java:224) 
     at org.codehaus.jackson.JsonFactory._createJsonParser(JsonFactory.java:785) 
     at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:561) 
     at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1923) 
     at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:122) 
+0

您是否找到答案? –

回答

1

的問題是正確的,在堆棧跟蹤: 「讀超時」。這意味着客戶端停止向服務器發送數據的時間過長,導致服務器放棄並假定連接丟失。然後,服務器無法解析JSON消息,因爲它沒有收到全部消息(因爲它放棄了等待客戶端發送其餘消息)。