cancel
Showing results for 
Search instead for 
Did you mean: 

What happens if JCO.Client object not disconnected?

Former Member
0 Kudos

Hi All,

Can anyone tell me what happens if a JCO.Client( which is connected to SAP) is not disconnected? Will it be connected? or JCO disconnects it after sometime? or SAP itself disconnects it?

JCO.Client client = JCO.createClient(....);

client.connect();

If I run this simple code and leave it, what will happen to the connection opened?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vijaya,

the connection stays open for a specific amount of time, which depends on the settings in the target ABAP system.

You can check this by executing the code lines in your post and check transaction SM04. There's a RFC user listed, which corresponds to your connection properties (look for the user name you specified). The connection stays in the list until the ABAP system terminates it. Common timeout is 10-30 minutes.

Regards

Stefan

Former Member
0 Kudos

Hmmm Stefan

How did you test that ? I tested it out by running a java application and plugged in a jco creation within the static void main and executed it and connection in SM04 died after the program exited.

Former Member
0 Kudos

Hmmm Pran,

i did the same test on different customer systems and the connections stayed open for some minutes? I have no idea why this is different from your observations. May be it's not possible to give an answer, which is correct in general, it might even depend on the JCO version used for testing.

Best regards

Stefan

Former Member
0 Kudos

Hi Stefan

This is what I used ? Can you please tell me what do you get when you exec this there in your env. Just curious...

public class test {

public static void main (String args[]){

JCO.Client jcoClient = JCO.createClient("555","user","pwd","EN","server04","01");

jcoClient.connect();

System.out.println("connected");

}

}

Former Member
0 Kudos

Hi Pran,

you're right and i'm totally wrong! The connection is closed, if the client instance if finalize()d. No chance to keep it open if the JVM terminates.

Thanks and regards

Stefan

Former Member
0 Kudos

Hi Vijaya,

forget my last answer. It's wrong. If the JVM terminates or the JCO client instance you created is released by the garbage collector, the connection is closed.

Pran gave the correct answer.

Sorry and regards

Stefan

Former Member
0 Kudos

Hi Stefan, Pran and Ravi,

Thank you very much for the answers.

Regards,

Vijaya Gopal.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Vijaya,

Did the replies help? Another question now?

If so, don't forget to assign points.

Click on the Yellow Star icon in each reply. You can give:

1 10 pointer (solves problem)

2 6 pointers (very helpful)

lots of 2 pointers (helpful)

Thanks!

Joan (and Mark Finnern)

Former Member
0 Kudos

Few cents.

a) Treat it just like Database Connection. i.e. dont forget to close it once done with it and dont rely on garbage collector or the timeout. I have seen scenarios where garbage collector didnt kick in and resources just started accumulating!!

b) Pool it for better performance or use JCA or JCOClientService.

Former Member
0 Kudos

Does "Out of memory" error which is an Internal server 500 error and the "Dispatcher running but no server connected" has any thing to do with JCO connection.

I have made jco connections and closed them using the disconnect. When the number of users were limited then we had no problems with the J2EE engine. But as the Users started to grow we are having problems with out of memory and dispatcher problems. Can any one please help with this problem.

Ravi

Former Member
0 Kudos

Hi,

You don't need to disconnect it explicitly.JCO automatically disconnects the idle connection after 10 minutes( Default value).If you want to change the time use method setConnectionTimeout(long connection_timeout)

on pool class.

Always try to use connection pooling. Go through the below documentation for class JCO.Pool.

This class encapsulates a connection pool. A pool is a set of client-connections to a certain destination. The pool may automatically create new connections to the specified remote system or return an already existing one. It also provides methods to return a connection back to the pool when it is no longer needed.

It checks periodically which connections are no longer in use and can be closed in order to save valuable system resources. The time period after which the pool checks the connections as well as the time after which a connection will time-out can be configured by the calling application.

But don't forget to release the client after your call execution.

Regards

Venkat

Message was edited by: venkat sudina

Former Member
0 Kudos

[snip]

"If so, don't forget to assign points.

Click on the Yellow Star icon in each reply. You can give:

1 10 pointer (solves problem)

2 6 pointers (very helpful)

lots of 2 pointers (helpful)"

I don't see a "Yellow Star" - What's up with that?

Former Member
0 Kudos

We are using JCO with SAP J2EE and have found something strange. We are setting the idle_timeout property and the SAP user is logging off, however we accumulate DISCONNECTED sessions in the SAP gateway. If the gateway limit is reached, additional connections fail. We used a modified version of the sample program to isolate the problem.

Test Program:

import java.io.IOException;

import com.sap.mw.jco.*;

public class Test {

public static void main(String args[]) {

byte instring[] = new byte[20];

JCO.Client jcoClient = JCO.createClient("200", "user", "password", "EN",

"bhha.na.pg.com", "00");

jcoClient.setProperty("idle_timeout","60");

jcoClient.connect();

System.out.print("Read:");

System.out.flush();

try {

System.in.read(instring);

} catch (IOException e) {

e.printStackTrace();

}

}

}

During 60 second period, transaction smgw shows the following information as expected. There is also a logged in user in SM04.

44 7BWGF21 javaw t0331 CONNECTED <unknown 99703871 INT 15:13:10 0 0

After 60 seconds, the user disappears from SM04, however the smgw connection goes to a disconnect state as follows.

44 7BWGF21 javaw t0331 DISCONNECT <unknown 99703871 INT 15:14:44 0 0

This session stays in this state until the enter key is pressed and the java app terminates. This is problem with a J2EE server app were the java process does not terminate.

Thanks,

Harry

Former Member
0 Kudos

Hi Vijaya

If you write a sample java code and execute the lines below then the as soon as the program exits from the memory your connection object is removed and no connection with SAP exists. If you want control on parameters such as maximum no of connections , connection time out , wait time etc , then use the JCO connection pool apis

Regards

Pran

Former Member
0 Kudos

As far as I know the JCo.Client connection depends on the HTTP Sessions. The HTTP session time out detects for any open clients when it session is about to become inactive. If there are any open connections then they will be disconnected.

I am not sure from the SAP perspective whether there exists any idle time for connection after when it will terminate the connection.