my dog learned polymorphism
The moose likes Sockets and Internet Protocols and the fly likes 	 Connection is already closed due to Firewall Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "	 Connection is already closed due to Firewall" Watch "	 Connection is already closed due to Firewall" New topic

Connection is already closed due to Firewall

ramandeep mann

Joined: Aug 17, 2006
Posts: 13
Hi All,

I have a query which is taking more then 2 hours to run on a remote machine .But my application server is behind the firewall so the firewall drops the connection while it is waiting for results from the remote machine after .Is there any way that i can keep this connection alive for more then one hour

Please help me .

Exception I am getting when remote machine returns the result.
Caught IOException: com.sybase.jdbc2.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed.
at com.sybase.jdbc2.jdbc.ErrorMessage.createIOEKilledConnEx(
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseErrorCheckDead(
at com.sybase.jdbc2.tds.Tds.handleIOE(
at com.sybase.jdbc2.tds.Tds.nextResult(
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(
at com.sybase.jdbc2.jdbc.SybStatement.executeLoop(
at com.sybase.jdbc2.jdbc.SybStatement.execute(
at com.sybase.jdbc2.jdbc.SybPreparedStatement.execute(
at TestDbConnect.connect(
at TestDbConnect.main(

Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

There may be ways of dealing with the problem of connection timeout that I do not know.
However, this whole thing really sounds wacky to me. I mean taking 2 hours to execute a query is something that really requires a design change.
If the job really takes too long in normal scenarios, why not make it an asynchronous process?
The client will post a request for processing and when the result is ready the status will be sent back to the client or updated somewhere, from where the client can pick up.

apigee, a better way to API!
ramandeep mann

Joined: Aug 17, 2006
Posts: 13
Well its a old application using Sybase as database e have more then 113 million records to process so time taken by it is normal.

I am getting your point but application was working fine from last 10 years before this new firewall was installed.

What we tried so far..
1.Ran a new thread calling the query on same connection but this query went into the sybase queue and is getting processed after the first query complete .So it was a fail attempt.What ever we are calling on sybase is being sent to a e are not able to keep connection busy to be up for long.

2.changing firewall setting is not a option with us.

3.We tried to make a socket connection on the same port so tht it is busy .and ran setKeepalive function on it.
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Obviously the problem is your new firewall. Certain configurations will interrupt existing but idle connections after a period of time. I ran into one at my employer. The security people would not disable this configuration, so we ended up doing as Nitesh suggests, and making the process asynchronous and sending an email when the process is done.

[How To Ask Questions On JavaRanch]
ramandeep mann

Joined: Aug 17, 2006
Posts: 13
I agree but is there a way to identify how Firewall is able to attenuate the connection.I don't see it killing the process on the specific Port.

How come a firewall detect the Connection object being ideal for two hours?.Thats funny
I agree. Here's the link:
subject: Connection is already closed due to Firewall
jQuery in Action, 3rd edition