Home Help Center

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

sudssuds Member Hongquan.ZhangOrganization: HUSTProject: StreamOut is a distribute streaming service
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

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    This shouldn't be happening because it violates at-most-once semantics. We'll have a look at this, thanks!

    Michi.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    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.
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    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.
  • sudssuds Member Hongquan.ZhangOrganization: HUSTProject: StreamOut is a distribute streaming service
    Oh ! It's my mistake .
    Thank you very much for your explanation
Sign In or Register to comment.