1

I have one Grails working on the server on Tomcat. This app is an web interface to export information from the MySQL server. This information can be exported depending on the selection that you did, but takes some time. The biggest part or process is around 40min. This is the time that it needs to export all the information from the database and return to user compressed in one zip file.

Everything is working correctly but we have a problem with one client. They have some kind of proxy installed and after 3 minutes of inactivity closes the connection with the server and he is not enable to export anything because all the combinations that he can select to export take longer.

The client side, the GSP page, doesn't do anything while the server side is calculating and creating the compressed file, is only waiting. What can I do to avoid this closing of the connection?

This is the message that is receiving the client:

Network Error (tcp_error) A communication error occurred: "" Detailed technical information: URL: **** Proxy: fe0psg03 Client Adress: 10.2.122.105 Time: [15/10/2012:15:41:40 GMT] User: DE\roklinne The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.

Thanks in advance for your support,

Marco Zimmerman
  • 241
  • 3
  • 10
  • 1
    Well, if your client cannot change this proxy rule, I think you will have to take a look in some background process, non-blocking your app and notifying your user when the process is done. –  Oct 17 '12 at 13:31

1 Answers1

1

Because this process is taking up to 40mins. I would consider spinning off a task and running it in the background.

couple of suggestions...

1) just use the Java 5 concurrency classes (little extra work)

2) JSR-166y library giving you handy abstractions for Fork/Join and Parallel Array.

3) The Background thread Grails plugin

The after this you could have a progress bar and give the user an update on how things are going.

nate_weldon
  • 2,289
  • 1
  • 26
  • 32
  • 2
    4) The [executor](http://grails.org/plugin/executor) plugin, generally preferred over background-thread these days. – Ian Roberts Oct 17 '12 at 14:12
  • Thanks for answering Sergio, Nate and Ian. I agree with you, but how can I communicate to the user that the file is ready? If the connection is going to be closed anyway? It wouldn't be better to send some kind of keep-alive signal or something like that and keep the connection open? – Marco Zimmerman Oct 17 '12 at 14:29
  • Ok, I agree that is the best solution to do in background. But once I have the file ready to be sent to the user, how can I send to him this file. I can't know on what page is him.. :( Someone has a clear idea? Sorry but I'm new on this, and I'm a little bit confused. – Marco Zimmerman Oct 18 '12 at 13:33
  • been looking though the grails-executor plugin docs and it states that the callAsync method returns a java.util.concurrent.Future object. This object can be used to do two things: Determine if a process has completed or been canceled. Cancel a running process (even interrupting if necessary). In theory, you should be able to save this Future in your user's session somewhere. Then you could retrieve it later and use it to check the status and/or cancel the process as necessary. – nate_weldon Oct 18 '12 at 14:40
  • And there would be no possibility to avoid this playing KeepAlive values ​​in Tomcat Connector? – Marco Zimmerman Oct 19 '12 at 13:46
  • i think the TCP layer keep-alive between client browser and Apache. (To avoid connection to be closed by firewalls, send empty packet periodically (around 2 hours by default in Linux). I don't know how to configure this in Apache.) – nate_weldon Oct 19 '12 at 17:03