讨论区 » AAS-V10敏捷版 »
启用https后,上传文件错误问题
问题描述:
在启用https协议时,发现文件上传有异常,如果文件稍微大一些,就会抛异常。异常如下:
26-Nov-2021 10:40:37.844 信息 [https-jsse-nio-6887-exec-2] com.apusic.connector.http11.Http11Processor.service 解析 HTTP 请求 header 错误
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: 在方法名称中发现无效的字符串, HTTP 方法名必须是有效的符号.
at com.apusic.connector.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:416)
at com.apusic.connector.http11.Http11Processor.service(Http11Processor.java:260)
at com.apusic.connector.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at com.apusic.connector.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at com.apusic.aas.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1678)
at com.apusic.aas.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at com.apusic.aas.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
或者
2021-11-25 15:33:52,099 [https-jsse-nio-8088-exec-1] ERROR [500.jsp] - Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:165)
at org.springframework.web.multipart.commons.CommonsMultipartResolver.resolveMultipart(CommonsMultipartResolver.java:142)
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:1067)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:906)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.apusic.aas.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.platform.common.filter.CSRFilter.doFilter(CSRFilter.java:42)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:450)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at com.apusic.ams.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at com.apusic.ams.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.apusic.ams.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at com.apusic.ams.core.StandardContextValve.invoke(StandardContextValve.java:96)
at com.apusic.ams.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at com.apusic.ams.core.StandardHostValve.invoke(StandardHostValve.java:139)
at com.apusic.ams.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at com.apusic.ams.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at com.apusic.ams.connector.ConnectorAdapter.service(ConnectorAdapter.java:343)
at com.apusic.connector.http11.Http11Processor.service(Http11Processor.java:367)
at com.apusic.connector.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at com.apusic.connector.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at com.apusic.aas.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1685)
at com.apusic.aas.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at com.apusic.aas.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Stream ended unexpectedly
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:351)
at org.apache.commons.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:115)
at org.springframework.web.multipart.commons.CommonsMultipartResolver.parseRequest(CommonsMultipartResolver.java:158)
... 64 more
Caused by: org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:1005)
at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:903)
at java.io.InputStream.read(InputStream.java:101)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:100)
at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70)
at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:347)
... 66 more
解决办法:经测试猜测是由于启用https协议后,aams的http11nio协议有问题,故将启用https的endpoint的协议由nio改成nio2后,经测试问题解决,nio的问题已反馈研发。
修改conf/apusic.conf ,改动点见红色字体
<endpoint name="https" port="5887" maxThreads="150" SSLEnabled="true" maxPostSize="1048576111111" protocol="com.apusic.connector.http11.Http11Nio2Protocol"
maxHttpHeaderSize="81920000000"
connectionTimeout="20000"
enableLookups="false"
keepAliveTimeout="15000"
clientAuth="false" sslProtocol="TLS" keystoreFile="conf/keystore.jks" keystorePass="changeit"
>
</endpoint>
关键字:https nio 上传文件