|
|
|
|||||
|
How to re-establish glacier2 session after connection explicitly closed?
I've just added support for glacier2 in my application and all is working with the initial connection establishment. My client application has a disconnect and connect button . When the disconnect button is selected all the connections are explicitly close by invoking ice_connection()->close(true) on all the proxies. This works when not using a glacier2 router, but when the router is enabled it looks like close(..) closes the glacier2 session. If the connect button is then selected the client cannot re-connect back to the server.
Does this sound like the expected behaviour and is there a way to re-establish the router session and connection if close has been invoked on the proxies connection? I've tried to do a few things, such as create a new router session again, but it doesn't appear to work. It seems like the router session needs to be created first, at least this is how all the examples are listed, and then the router is added to the adapter. I've also removed all invocations of close(..), and this appears to work, but I'm not sure if there are some other issues with my application when doing this so I'll need to do some more experimenting. If I can't create a new session then is the only other alternative to not invoke close(...)? Regards --Roland |
|
|||||
|
Hi Marc, Here is where I'm at.
1. First time through everything works as expected. 2. After the disconnect button is selected all the proxies that the client created to the server are force closed. 3. The second time through ForcedCloseConnectionException occurs when trying to invoke router->createSession(...) I noticed that if I selected the connect button again the ForcedCloseConnectionException does not occur. 4. I added another invocation of router-createSession(...) in the catch block if the first one failed as follows: try { router->createSession(...) } catch (const Ice::Exception&) { try { router->createSession(...) } catch (const Ice::Exception&) { throw; } } Surprisingly the 2nd invocation of createSession passes. 5. Unfortunately a few lines later, when I try to create a new proxy to the server using a checked cast the client emits a ConnectionLostException. Incidentally, despite my earlier post, I was able to create the object adapter without having a router session yet so that part is working. Regards --Roland |
|
||||||
|
Hi Roland,
Could you try to enable retries in your client? The manual used to say not to use retries with Glacier2. In fact retries are not harmful with Glacier2, but they should not be useful either (since you need to recreate a session when an error occurs and the connection is closed). We are however aware of a bug in Ice where an invocation on a proxy-with-a-closed-connection is not attempted even once, and it looks like you're hitting this bug. Retries is a good work-around. We'll fix this bug soon. Best regards, Bernard |
|
|||||
|
Hi Bernard, That helped. Adding retries allowed the 2nd invocation of router->createSession(..) to pass.
I'm now seeing a different issue. A few lines later in the code the proxy to the server is created using stringToProxy(...). Then it is converted to a secure twoway proxy using a checked cast and this fails with ObjectNotExistException. After I create a new router session is there anything else that I need to do? Regards --Roland
__________________
Roland Hochmuth Hewlett-Packard 3404 East Harmony Rd. Fort Collins, CO 80528 |
|
|||||
|
Hi Bernard and Marc, Just a couple of other items.
The 1st time through everything works and things are done in this order. 1. Create object adapter. 2. Get default router and add the router to the adapter. 3. Activate the adapter. 4. Create the router session. 5. Get the proxy to the server. 6. Create the clien callback object, get router category and add to id, add callback object to object adapter and get the local proxy. 7. Register the client callback proxy with the server. When the disconnect button is selected, all the connections are explicitly closed on the client side. When connect button is selected again we start with step 4 above just creating a new router session. At step 5 is where the ObjectNotExistException exception occurs when doing a checked cast, but it is the same exact code path as is the first time pass. If a re-start the client application everything works the first pass through again. Regards --Roland
__________________
Roland Hochmuth Hewlett-Packard 3404 East Harmony Rd. Fort Collins, CO 80528 |
|
||||||
|
Hi Roland,
I've been looking into your problem. A couple of questions. What version of Ice are you using? Have you tried Ice 3.0? Your instructions I don't think are quite correct. You cannot add the router to the object adapter until you've established a session since this makes an invocation on the router which is rejected if the session is not yet established. I've been able to get the chat demo to work, but I had to make a couple of unexpected changes. I'm investing the exact reason -- sorry about the delay. |
|
|||||
|
Hi Mathew, We're using Release 2.1.0. I haven't tried Release 3.0 yet.
Your right about the session. I always create the router session before the object adapter. My mistake. Thanks for looking into this! Regards --Roland
__________________
Roland Hochmuth Hewlett-Packard 3404 East Harmony Rd. Fort Collins, CO 80528 |
|
|||||
|
Any change in ability to re-establish glacier2 session?
Quote:
Code:
ice = new IceServiceFactory(); // creates communicator
ice.createSession(); // gets router and session
ice.longRunningAsyncTask();
String id = ice.getSessionId(); // uses comm.proxyToString()
ice.destroy(); // destroys communicator
// creates a new communicator
ice = new IceServiceFactory();
ice.useSession(id); // fails with Ice.ConnectionLostException on checked cast
ice.checkOnLongRunningTask();
|
|
||||||
|
Hi,
No, this hasn't changed. A session is transient and is considered destroyed when the connection to the router is closed. So you should re-create a new session instead of trying to re-use the previous one and register new callback objects with the server to get notifications from the server regarding your long running task. Let us know if you need more informatin! Cheers, Benoit. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Session Management with Glacier2 question | 123w456t | Help Center | 1 | 03-29-2006 06:46 PM |
| Glacier2 session expiration | Nis Baggesen | Help Center | 10 | 03-21-2006 08:05 AM |
| Session | dashie | Help Center | 3 | 02-19-2006 10:40 PM |
| Glacier2 checkedCast loses connection... | Unreasonable | Help Center | 7 | 11-01-2005 03:30 PM |
| How to use session? | Dmitriy | Help Center | 2 | 06-18-2004 10:22 AM |