Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2008
bxhsix bxhsix is offline
Registered User
 
Name: Dong Wang
Organization: Harbin Institute of Technology
Project: Data transportation
 
Join Date: Mar 2008
Posts: 19
Question About Ice.RetryIntervals and client information

Hi all!
I am new in ICE and want to transport files with it.
I set Ice.RetryIntervals=0 10 20, expecting the client will retry three times when the server is down. But in fact when the server was down, the client retried unlimitedly. Can you tell me what's the matter?
On the other hand, I want to know whether the server can get the client's information such as IP when it is connected except the client provides it as the parameter of call.
Thank you very much!
Reply With Quote
  #2 (permalink)  
Old 03-25-2008
bxhsix bxhsix is offline
Registered User
 
Name: Dong Wang
Organization: Harbin Institute of Technology
Project: Data transportation
 
Join Date: Mar 2008
Posts: 19
Exclamation

But I need help! What I want is simple:
1)When the client can't connect to the server because of any reason, for example, the network is broken, the server isn't running, the server shutdown suddenly, etc., the client can retry certain times and then stop connecting and throw an exception.
2)When the client run a RPC, the server can get the client's information such as IP and port, given that the client dosen't provide it explicitly.
Anyone can tell me what I should do? Thanks a lot!
Reply With Quote
  #3 (permalink)  
Old 03-25-2008
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 912
The first thing to try is to enable Ice.Trace.Retry=2 and Ice.Trace.Network=2for both client and server. This will allow you to see connection establishment and closure, and to follow the rety behavior. I suspect that the server might accept the connection but then close (orderly) for some reason.

Also, what version/language are you using?

Cheers,

Michi.
Reply With Quote
  #4 (permalink)  
Old 03-25-2008
bxhsix bxhsix is offline
Registered User
 
Name: Dong Wang
Organization: Harbin Institute of Technology
Project: Data transportation
 
Join Date: Mar 2008
Posts: 19
Thanks michi!
I use Ice-3.2.1/C++ and my code is like this:

//TransferFile.ice
module File
{
sequence<byte> byteSeq;

interface TransFile
{
void SaveFile(byteSeq buf, int len, string filename);
};
};

//Client.cpp
#include <Ice/Ice.h>
#include <fstream>
#include "TransFile.h"

using namespace std;
using namespace File;

const int SIZE = 100;

int main(int argc, char *argv[])
{

if (argc != 2)
{
printf("Usage: %s Filename\n", argv[0]);
return 1;
}

int status = 0;
Ice::CommunicatorPtr ic;

File::byteSeq buf;
buf.resize(SIZE + 1);

try
{
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base = ic->stringToProxy("FileTransform:default -h 192.168.1.42 -p 10000");
TransFilePrx transFiler = TransFilePrx::checkedCast(base);
if (!transFiler)
throw "Invalid Proxy";

ifstream inFile("file");
while (1)
{
inFile.read((char *)&buf[0], SIZE);
if (inFile.gcount() == 0)
break;
transFiler->SaveFile(buf, inFile.gcount(), argv[1]);
}
inFile.close();
}
catch (const Ice::Exception &e)
{
cerr << e << endl;
status = 1;
}
catch (const char *msg)
{
cerr << msg << endl;
status = 1;
}

if (ic)
ic->destroy();

return status;
}

//Server.cpp
#include <Ice/Ice.h>
#include <fstream>
#include <iostream>
#include "TransFile.h"

using namespace std;
using namespace File;

class TransFileI: public TransFile
{
public:
virtual void SaveFile(const File::byteSeq &buf, int len, const string &filename, const Ice::Current &);
};

void TransFileI::SaveFile(const File::byteSeq &buf, int len, const string &filename, const Ice::Current &)
{
ofstream outFile(filename.c_str(), ios::app);
outFile.write((char *)&buf[0], len);
outFile.close();
}

int main(int argc, char *argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;

try
{
ic = Ice::initialize(argc, argv);
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints
("SimpleFileTransform", "default -p 10000");
Ice::ObjectPtr object = new TransFileI;
adapter->add(object, ic->stringToIdentity("FileTransform"));
adapter->activate();
ic->waitForShutdown();
}
catch (const Ice::Exception &e)
{
cerr << e << endl;
status = 1;
}
catch (const char *msg)
{
cerr << msg << endl;
status = 1;
}

if (ic)
{
try
{
ic->destroy();
}
catch (const Ice::Exception &e)
{
cerr << e << endl;
status = 1;
}
}

return status;
}

//Ice_config
Ice.RetryIntervals=0 5000 10000

I run the code in such four conditions as follows:
1)run the client but the server is not running(the host 192.168.1.42 is connected): the client will retry three times as I expected and then throw a ConnectionRefusedException;
2)run the client but the host 192.168.1.42 is disconnected: the client will retry three times as I expected and then throw a ConnectionFailedException;
3)run the client and server both but shutdown the server(ctrl+c) while transporting the file: the client will throw a ConnectLostException immediately without retry three times as I expected;
4)run the client and server both but disconnect the host 192.168.1.42(for example, pull out the network cable): the client will wait for about 15 minutes and then throw a SocketException;

In the first and second condition, the result is what I need, because they both retry three times as I configure; However, in the last two conditions, I also want the client retry three times as I configure but it doesn't. So can you tell me what is the matter? In what way can the client perform just as what I want in the last two conditions?

Thanks again!
Reply With Quote
  #5 (permalink)  
Old 03-25-2008
benoit's Avatar
benoit benoit is online now
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,542
Hi,

The invocation isn't retried in #3 because it's probably not safe to do so without violating at-most-once semantics, see At-Most-Once Semantics in the Ice manual for more information.

In #4, you most likely get hangs because you don't use timeouts. In the case of an unreachable host, it can take few minutes for the TCP/IP stack to return with a connection failure condition. You should set Ice.Override.ConnectTimeout to a suitable value to not wait for so long.

Cheers,
Benoit.
Reply With Quote
  #6 (permalink)  
Old 03-25-2008
bxhsix bxhsix is offline
Registered User
 
Name: Dong Wang
Organization: Harbin Institute of Technology
Project: Data transportation
 
Join Date: Mar 2008
Posts: 19
Thanks Benoit! Thanks Michi! I know it.
But I am glad if you can answer my second question that whether the servant can get the client's information(IP or port) by some means without the client providing it explicitly.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to extend ICE log information? vshevchenko Help Center 2 02-06-2008 01:57 PM
Setting RetryIntervals below application level ctennis Help Center 4 12-21-2006 08:02 PM
ICE connection lifecycle information/implementing recovery mcrystal Help Center 1 09-28-2006 06:04 PM
Availability of Client Endpoint information to the sever object implementation Harvinder Comments 11 08-02-2004 06:38 AM
Background Information mick Comments 1 02-27-2003 07:27 AM


All times are GMT -4. The time now is 11:27 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.