解决文件上传 java.io.EOFException: Unexpected EOF read on the socket问题

解决springboot 文件上传 java.io.EOFException: Unexpected EOF read on the socket问题

问题原因,上传文件还没到末尾就被客户端中断,是超出tomcat文件连接时间了,就被跳转。

解决方案

在application.yml配置文件里加上一个tomcat连接时长

server:
  connection-timeout: 18000000

添加文件配置类


@Configuration
public class CommonConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize(1024 * 1024); // 限制上传文件大小
        return factory.createMultipartConfig();
    }
}
org.springframework.remoting.RemoteAccessException: Cannot access Hessian remote service at [http://localhost:8080/sso-service/hessian/tempTokenService]; nested exception is java.io.EOFException: r adObject: unexpected end of file at org.springframework.remoting.caucho.HessianClientInterceptor.convertHessianAccessException(HessianClientInterceptor.java:293) at org.springframework.remoting.caucho.HessianClientInterceptor.invoke(HessianClientInterceptor.java:265) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) at com.sun.proxy.$Proxy100.getTempTokenByTicketId(Unknown Source) at com.mango.service.passport.api.TempTokenApi.getTempTokenByTicketId(TempTokenApi.java:24) at com.mango.passport.interceptor.SecurityInterceptor.getTicketIdAndSetCookie(SecurityInterceptor.java:135) at com.mango.passport.interceptor.SecurityInterceptor.preHandle(SecurityInterceptor.java:64) at org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:958) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.ecog.tingjia.base.CaseInsensitiveParametersFilter.doFilterInternal(CaseInsensitiveParametersFilter.java:20) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Caused by: java.io.EOFException: readObject: unexpected end of file at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2164) at com.caucho.hessian.io.AbstractMapDeserializer.readObject(AbstractMapDeserializer.java:67) at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1835) at com.caucho.hessian.io.Hessian2Input.readReply(Hessian2Input.java:382) at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:195) at com.sun.proxy.$Proxy99.getTempTokenByTicketId(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.remoting.caucho.HessianClientInterceptor.invoke(HessianClientInterceptor.java:248); ***以上是在服务器上抓取的异常.所有依赖的hessian版本4.0.37, jdk1.7/1.8都尝试,据网上查找资料,重载方式已经设置为true, 地址在本地访问显示405是正常.
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页