|
|
|
|||||
|
Bi-directional conn. reestablishment
Hi,
I've got a client that makes a bi-directional connection with a server. I thought that I had found a way to detect when the server went down and have the client properly reestablish the connection. This seemed to fail the other day in production, though I have yet to get it to fail in test. What I do on the client is have a thread that pings the server every so often. After the ping, I check to see if the adapter registered on the connection is NULL, if so, I reset the adapter and register the callback object with the server. Should this ALWAYS work? Any suggestions or thoughts appreciated. Code:
ScheduleVersionIFPrx ver;
Ice::Identity ident;
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(m_connMonitor);
Ice::ObjectAdapterPtr adapter = m_server->adapter();
try {
ident.name = IceUtil::generateUUID();
adapter->add(m_listener, ident);
m_scheduleServer->ice_connection()->setAdapter(adapter);
m_scheduleServer->regTxListenerIdent(ident, m_listener->lastReceived());
//
// Do a ping every once in a while to test the state of the connection. If the
// connection is the same as before, nothing happens. If the connection was
// reestablished, set the adapter and register the listener. If the connection
// can't be reestablished (server down), throw and exception and let everything
// start over.
//
while (true) {
m_scheduleServer->ice_ping();
if (m_scheduleServer->ice_connection()->getAdapter() == 0) {
m_scheduleServer->ice_connection()->setAdapter(adapter);
m_scheduleServer->regTxListenerIdent(ident, m_listener->lastReceived());
}
}
}
__________________
-- Andrew Bell National Resources Inventory Center for Survey Statistics & Methodology Iowa State University andrew.bell.ia@gmail.com |
|
|||||
|
Thanks
There was a sleep in there. I must have removed it in haste when I posted the code. As long as this *should* work, I won't fret.
Thanks again,
__________________
-- Andrew Bell National Resources Inventory Center for Survey Statistics & Methodology Iowa State University andrew.bell.ia@gmail.com |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|