在大文件上传过程中,Grails连接超时 [英] Grails connection timeout during large fileupload
问题描述
如果用户尝试从我的Grails Web应用程序中的上载表单上载大文件,我想防止在大约1分钟后发生的 SocketTimeoutException
。我知道这是一个Tomcat的东西,而不是一个Grails的东西,但我正在努力修改 server.xml
使用 eventConfigureTomcat
事件块在 _Events.groovy
。
根据托姆特文档有一个 disableUploadTimeout
属性,我应该设置为 true
在连接器上,但是当我在 eventConfigureTomcat
块中尝试这个时,我的应用程序启动时出现以下错误:
|运行Grails应用程序
|错误服务器无法启动:无此类属性:disableUploadTimeout类:org.apache.catalina.connector.Connector(使用--stacktrace查看完整跟踪)
我的 _Events.groovy
的内容如下所示:
eventConfigureTomcat = {tomcat - >
tomcat.connector.disableUploadTimeout =true
}
没有任何意义 - 根据javadoc,在该连接器实现上没有属性 disableUploadTimeout
。
我做错了什么?我应该如何设置这个属性,或者是否有其他方法来防止长时间运行的文件上传超时?
避风港没有检查,但看看tomcat文档,你想修改的配置似乎是连接器的属性。
连接器有一个方法叫做 setAttribute 。所以我猜你会用下面的代码获得成功:
$ p $ eventConfigureTomcat = {tomcat - >
tomcat.connector.setAttribute('disableUploadTimeout',true); //可能'真的'
}
不得不承认我无法测试这个代码自己...
$ b $更新:根据@查尔斯伍德,它必须设置为 false
和不是真的
。
PS:如果您发布更多关于如何重现问题的信息,我会给它一个尝试
I want to prevent the SocketTimeoutException
that occurs after about 1 minute if a user tries to upload a large file from an upload form in my Grails web application. I know this is a Tomcat thing rather than a Grails thing, but I'm struggling a bit to modify server.xml
using the eventConfigureTomcat
event block in _Events.groovy
.
According to the tomcat docs there is a disableUploadTimeout
property that I should set to true
on the connector, but when I try this in the eventConfigureTomcat
block, I get the following error when my app starts up:
| Running Grails application
| Error Server failed to start: No such property: disableUploadTimeout for class: org.apache.catalina.connector.Connector (Use --stacktrace to see the full trace)
The contents of my _Events.groovy
looks like this:
eventConfigureTomcat = { tomcat ->
tomcat.connector.disableUploadTimeout = "true"
}
And that error does make sense - according to the javadoc, there is no property disableUploadTimeout
on that connector implementation.
What am I doing wrong? How should I be setting this property, or is there some other way to prevent long running file uploads from timing out?
haven't checked it, but taking a look at the tomcat documentation, the configuration you want to modify seems to be an attribute of the Connector.
The Connector has a method called setAttribute. So I guess you'll succeed with the following code:
eventConfigureTomcat = { tomcat ->
tomcat.connector.setAttribute('disableUploadTimeout', true); //may 'true'
}
have to admit that I couldn't test this code myself...
Update: according to @Charles-Wood , it has to be set to false
and not true
.
PS: if you post more information on how to reproduce your problem, I will give it a try
这篇关于在大文件上传过程中,Grails连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!