ClientAbortException来自哪里?

时间:2017-01-19 22:02:54

标签: spring spring-mvc tomcat spring-boot

我有一个Spring-Boot应用程序,它在日志中不断显示此错误:

  

[xec-104] ERROR异常处理ErrorPage [errorCode = 0,location = / error]   org.apache.catalina.connector.ClientAbortException:java.io.IOException:   连接由同行重置   org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:340)   在org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:303)   在   org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.j   ava:109)at   com.fasterxml.jackson.core.json.UTF8JsonGenerator.flush(UTF8JsonGenerator.j   ava:1048)at   com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:95   3)在   org.springframework.http.converter.json.AbstractJackson2HttpMessageConverte   r.writeInternal(AbstractJackson2HttpMessageConverter.java:285)at   org.springframework.http.converter.AbstractGenericHttpMessageConverter.writ   e(AbstractGenericHttpMessageConverter.java:100)at   org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConver   terMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethod   Processor.java:231)at   org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProce   ssor.handleReturnValue(HttpEntityMethodProcessor.java:203)at at   org.springframework.web.method.support.HandlerMethodReturnValueHandlerCompo   site.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81)at at   org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandl   erMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:132)at   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandler   Adapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)at at   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandler   Adapter.handleInternal(RequestMappingHandlerAdapter.java:738)at   org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.han   dle(AbstractHandlerMethodAdapter.java:85)at   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServ   let.java:963)at   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServl   et.java:897)at   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkSe   rvlet.java:970)at   org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.jav   a:861)在javax.servlet.http.HttpServlet.service(HttpServlet.java:622)   在   org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.j   ava:846)at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)   在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(应用A   nFilterChain.java:230)at   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC   hain.java:165)at   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher   .java:726)at   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDi   spatcher.java:471)at   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatc   her.java:394)at   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatche   r.java:311)at   org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:39   5)在   org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:25   4)在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:17   7)在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79   ) 在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.jav   a:87)at   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)   在   org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)   在   org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.jav   a:66)at   org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtoc   ol.java:802)at   org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.ja   va:1410)at   org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java   :49)在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1   142)在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:   617)在   org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.j   ava:61)at java.lang.Thread.run(Thread.java:745)   引起:java.io.IOException:由peer重置连接   at sun.nio.ch.FileDispatcherImpl.write0(Native Method)   at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)   在sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)   at sun.nio.ch.IOUtil.write(IOUtil.java:65)   at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471)   在org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134)   在   org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.ja   va:101)at   org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157)   在   org.apache.tomcat.util.net.NioEndpoint $ NioSocketWrapper.doWrite(NioEndpoint   .java:1221)at   org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking(SocketWrapperBas   e.java:451)at   org.apache.tomcat.util.net.SocketWrapperBase.flush(SocketWrapperBase.java:4   41)在   org.apache.coyote.http11.Http11OutputBuffer.flushBuffer(Http11OutputBuffer。   java:514)at   org.apache.coyote.http11.Http11OutputBuffer.flush(Http11OutputBuffer.java:2   43)在   org.apache.coyote.http11.Http11Processor.flush(Http11Processor.java:1495)   在org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:284)   在org.apache.coyote.Response.action(Response.java:167)   在org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:336)   ...省略了41个常见帧

如您所见,堆栈跟踪不会从我的应用程序中显示任何内容。此异常仅发生在基础结构中。它是什么意思,我该如何重现?另外,我不知道为什么杰克逊会在筹码中找到原因。我的应用程序中没有任何JSON输出。

最后,我想了解我的应用程序是否存在问题。如果是这样,请修复它。如果没有,我不想在我的日志中将其作为错误。

编辑:根据要求,这是pom.xml:



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>net.mixclouddownload</groupId>
	<artifactId>downloader</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.4.3.RELEASE</version>
	</parent>

	<properties>
		<java-version>1.8</java-version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.retry</groupId>
			<artifactId>spring-retry</artifactId>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
		</dependency>
		<dependency>
			<groupId>net.bull.javamelody</groupId>
			<artifactId>javamelody-core</artifactId>
			<version>1.63.0</version>
		</dependency>
		<dependency>
			<groupId>net.sf.jtidy</groupId>
			<artifactId>jtidy</artifactId>
			<version>r938</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>bootstrap</artifactId>
			<version>4.0.0-alpha.6</version>
		</dependency>
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>font-awesome</artifactId>
			<version>4.7.0</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.5</version>
		</dependency>
		<dependency>
			<groupId>com.ibm.icu</groupId>
			<artifactId>icu4j</artifactId>
			<version>58.2</version>
		</dependency>
		<dependency>
			<groupId>org.webjars.bower</groupId>
			<artifactId>bootstrap-social</artifactId>
			<version>5.0.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
		</dependency>
		<dependency>
			<groupId>org.twitter4j</groupId>
			<artifactId>twitter4j-core</artifactId>
			<version>4.0.6</version>
		</dependency>
		<dependency>
			<groupId>org.facebook4j</groupId>
			<artifactId>facebook4j-core</artifactId>
			<version>2.4.8</version>
		</dependency>
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>21.0</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-cache</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.cache</groupId>
			<artifactId>cache-api</artifactId>
		</dependency>
		<dependency>
			<groupId>ca.pjer</groupId>
			<artifactId>logback-awslogs-appender</artifactId>
			<version>0.1.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>3.5</version>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>${java-version}</source>
					<target>${java-version}</target>
					<compilerArgument>-Xlint:all</compilerArgument>
					<showWarnings>true</showWarnings>
					<showDeprecation>true</showDeprecation>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<executable>true</executable>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:7)

这是因为客户端在Tomcat有机会写出响应之前关闭了连接。

此异常的主要实施者往往是“Internet Explorer”,因为它处理资源连接(如下载JavaScript,CSS,图标等);如果它决定它不再需要资源,它会在服务器有机会写出来之前关闭连接。当你在IE中使用Angularjs或其他SPA框架时,我也会看到更多。您将知道它是由IE引起的,因为请求资源路径是资源文件(如前所述)。

第二个(或同样?)最常见的罪魁祸首可能是用户在有机会完成加载之前多次刷新页面,或者用户在页面加载完成之前导航。

第三个罪魁祸首,不太常见,但更令人愤怒的是,当你在自己的网络上呼叫服务时。您将在被调用的服务上看到“ClientAbortException”,并在客户端服务上看到“SocketException:connection reset”。原因通常是因为防火墙配置不当。我和我的系统管理员聊过,她说上次发生在我身上的原因是因为在高峰使用期间复制流量太高,所以防火墙无法及时返回数据包。解决方案是在其他重要应用程序的高峰使用期间限制来自特定来源(例如复制)的流量。我想你可以通过模拟大量使用和通过防火墙的流量来复制这个错误。