Archived

This forum has been archived. Please start a new discussion on GitHub.

server's method get called twice while client received a TimeoutException

Hi :
I have modified the demo project hello's source code , and after some test I found a wierd problem.
In function sayHello of HelloI.cpp in server side
int HelloI::sayHello(int index, const Ice::Current&) const
{
  

	cout<<"call's index = "<<index<<endl;//display index passed from client
	IceUtil::ThreadControl::sleep(
		IceUtil::Time::milliSeconds( _delay ));//_delay is a pre-set value 
	

    return 1;
}

at the client side:
	int iCount = 0;
	while(!bQuit)
	{
		try
		{
			cout<<"call's index = "<<iCount <<endl;
			hPrx->sayHello(iCount);//call server's hello and tell it current index
		}
		catch( const Ice::Exception& ex)
		{
			cout<<ex.ice_name()<<endl;
		}
		iCount ++;
	}

If I set _delay in server side to 5000 ms , and in my client's code, I set the hello proxy's timeout to 2000. we'll see that the same index will appear twice on server side's console.
That is , if client detected server timed out , it'll invoke the routine again.
attached is a screen shot and the zip of source code.

Comments

  • This shouldn't be happening because it violates at-most-once semantics. We'll have a look at this, thanks!

    Michi.
  • benoit
    benoit Rennes, France
    Actually, this is the expected behavior for idempotent operations. If you remove the idempotent keyword from the Slice, the retry won't occur to ensure at-most-once semantics are not violated.

    See the section "Idempotent Operations" here in the Ice manual for more information.

    Cheers,
    Benoit.
  • Ah, yes, I should have looked at the Slice definition. Benoit is right, of course. If you mark the operation as idempotent, the retry is just what should happen.

    Cheers,

    Michi.
  • Oh ! It's my mistake .
    Thank you very much for your explanation