aspose file tools*
The moose likes BEA/Weblogic and the fly likes Is there socket_keepalive equivalent in Weblogic? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Is there socket_keepalive equivalent in Weblogic?" Watch "Is there socket_keepalive equivalent in Weblogic?" New topic
Author

Is there socket_keepalive equivalent in Weblogic?

John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
I know tomcat has it. I got a firewall between my WebServer and my users, connections will be dropped after certain time. How to configure Weblogic to send out keepalive packets?

Thanks!
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
By default this option is enabled in WL 8.1. You can check the setting in the admin console by navigating to
Servers > {your_server} > Protocols > Http
the http page has all the options listed.

Alternatively you can also verify the config.xml. This property wont be listed if it's enabled.
element : WebServer
parent: Server.

You can search the weblogic docs for config.xml entries and navigate through to WebServer element to see the option.
John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
I think the one you talked about is not what I want.

The keepalive setting in Weblogic --> protocol --> http is for the server to keep the server-client connection alive for certain time after a request is finished, so the following request from the same client can use the connection without creating a new one.

Our company firewall/proxy server have a timeout limit, it will kill any idle connection of more than 5 minutes. Unfortunately some of my Weblogic request take a long time to process, so the client-server connection will be dropped before the server can present the page. What I want is to configure Weblogic so that it can send out keep-alive packet while processing the long request, so the connection won't be killed by proxy.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Welcome to the JavaRanch, Fly.
You must have missed our naming policy on your way in. In short, names must be a first name and last name, separated by a space and not obviously fake. You can change your name here.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
I only have limited knowledge on weblogic 8.1. However I did not see any related configuration on weblogic server admin console , plugin and start script. Maybe it is not supported in weblogic.

By the way , I think what you mentioned is finally implemented by SO_KEEPALIVE at the TCP layer. By default it is two hours. Do you have a way to change it?

Thanks

Lin
John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
SO_KEEPALIVE, that is what I am talking about. Too bad if Weblogic doesn't support this. The socket_keepalive in Tomcat will trigger the operating system to send keep-alive packet, interval depend on SO_KEEPALIVE setting, generally 120mn, that still is too long.

Does anybody know how to permanently change the SO_KEEPALIVE value in the operating system (windows)?
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
It can be changed as http://publib.boulder.ibm.com/infocenter/tivihelp/v1r1/index.jsp?topic=/com.ibm.itsmreadme.doc/rdme5327.htm

Can you change the SO_KEEPALIVE setting on your web server side? If you so the SO_KEEPALIVE package can be sent from the client side, WebLogic does not have to be done with any change.

Thanks

Lin
[ August 22, 2006: Message edited by: Lin Feng ]
John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
Thanks, Lin, you are very helpful!

I changed the KeepAliveTime on the server side, so the server can now send keep-alive packets at a shorter interval.

But I think more still need to be done. It says on another website: "A specific application can request that keep-alive packets be sent", so I guess the TCP/IP connection will not automatically be kept alive unless the application request it. I guess that's what socket_keepalive setting in TOMCAT is all about.
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425

so I guess the TCP/IP connection will not automatically be kept alive unless the application request it


That's true. Keep-alive is not specific to java but to Http 1.1 specification. The specification points out that this is driven by client and not by server. As you think this is not something specific to Tomcat but to Java. Second you still have problem with your firewall settings. No matter what value you configure as KEEPALIVE setting firewall will close the inactive sockets based on it's rule.
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
Sorry, I made a mistake in the previous reply.

As we know the tomcat supports it. If you can build a proxy by using tomcat and put it in front of the firewall, it might be done.

By the way , the keep alive in this context is the TCP one.
Lin
[ August 23, 2006: Message edited by: Lin Feng ]
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
I think I was too stubborn on the SO_KEEPALIVE.

Let's take a step back to see what else can be done

1) Can the firewall timeout setting be changed? It might be rejected by Admin group

2) Can the procedured to be optimized to finish in 5 minutes? It may be a challange and time consuming task.

3) I assume this is a web application becuase both Tomcat and WebLogic are in the context. Can the page be changed to async? I am sure this can be done By using Ajax or just a simple hidden IFrame , the page can be changed to an async page. Then there is no requirement to keep the connection for 5 minutes. Anohter reason to change the page to async is that the user will lost patient when they are waiting for the result.


Hope this help.

Lin
John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
Lin, thanks for your input, that's very helpful!

I think I will give up trying SO_KEPPALIVE, even I set up everything right, the firewall or proxy still kills the connection at 5 minutes, so I guess keep-alive doesn't work in my case.

I don't have the freedom to change my page to async or refresh itself due to many reasons.

Howerver, I found in my test jsp page, if I do out.flush(" ") at 1 or 2 minutes interval, it will keep my connection going, so I guess that could be a solution.

suppose my JSP code is like this,
<%
...
Obj.heavyProcess();
...
%>

How can I start a new thread to do out.flush(" ") while the heavyProcess is going on? If I can do that, I think the problem could be solved.

Thanks!
John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
sorry, out.flush(" ") is actually

out.println(" ");
out.flush();
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
I am not sure what is your exact circumstance.

I would do something like below

1)create my own response class which has a build in buffer to hold the output.
2)create a new thread to execute the heave task. Pass in my own response object . It will bring back the response
3) kick off the new thread to execute the heave task
4) the main execution thread is doing the sending back to keep the connection alive and sleeping , check if the heavy task has been done
5) When the heave task has been done , get the content from the response object and send it back to client
John Smith
Greenhorn

Joined: Aug 21, 2006
Posts: 13
Lin, I think I figured out why socket_keepalive doesn't work. It is used to keep connection between tomcat/IIS or tomcat/Apache open if they reside on different machines. It is not used to keep the browser/IIS or browser/Apache connection. That's my understanding.

Unfortunately I don't know how to configure IIS or Apache to do the same thing.
Lin Feng
Ranch Hand

Joined: Dec 11, 2002
Posts: 142
John,

There should be no difference between these 2 cases. When we talk about the TCP layer to a server , there is no difference for the connection either it is from a proxy or it is from the client directly. It is only a connection.

Only in your code you may need to know the exact client address.

The reason Apache/Tomcat can support SO_KEEPALIVE is the tomcat should set the SO_KEEPALIVE when the connection was built.


Lin
[ August 23, 2006: Message edited by: Lin Feng ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is there socket_keepalive equivalent in Weblogic?