The simplest solution is to completely disable collocation optimization in clients that make asynchronous invocations. You can disable it by setting Ice.Default.CollocationOptimized=0. If you still want to take advantage of collocation optimization for synchronous invocations, you can enable it on a per-proxy basis like this:
Code:
HelloPrx proxy = ...;
proxy = proxy->ice_collocationOptimized(true);
proxy->sayHello();
Another solution is to leave it enabled by default and disable it individually for each proxy that you will use for asynchronous invocations:
Code:
HelloPrx proxy = ...;
proxy = proxy->ice_collocationOptimized(false);
proxy->begin_sayHello();
Finally, you can trap CollocationOptimizationException and try again:
Code:
HelloPrx proxy = ...;
while(true)
{
try
{
proxy->begin_sayHello();
break;
}
catch(const Ice::CollocationOptimizationException&)
{
proxy = proxy->ice_collocationOptimized(false);
}
}
Regards,
Mark