Archived
This forum has been archived. Please start a new discussion on GitHub.
IceBox Conection refused

xdm
La Coruña, Spain
in Help Center
Hellow I trying to implement an ::IceBox::FreezeService
heare is the code of start method
void
TiendaServiceI::start(const std::string& name, const
Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args, const std::string&)
{
TiendaRezI::_adapter =communicator->createObjectAdapter(name);
ObjectFactoryPtr factory = new TiendaRezFactory();
communicator->addObjectFactory(factory,TiendaRezPersistent::ice_staticId());
TiendaRezI::_evictor = Freeze::createEvictor(communicator,"TiendaDb","tiendaDb");
Ice::Identity idTienda=Ice::stringToIdentity("1");
idTienda.category="tienda";
if (!TiendaRezI::_evictor->hasObject(idTienda))
{
TiendaRezIPtr tienda=new TiendaRezI();
TiendaRezI::_evictor->createObject(idTienda,tienda);
}
TiendaRezI::_evictor->setSize(1000);
}
i creating then an Ice::Application for the client
int Client::run(int argc, char*argv[])
{
Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "TiendaRez.Proxy";
std::string proxy = properties->getProperty(proxyProperty);
cout<<"Proxy: "<<proxy<<endl;
if(proxy.empty())
{
cerr << argv[0] << ": property `" << proxyProperty << "' not set" << endl;
return EXIT_FAILURE;
}
Ice::ObjectPrx object= communicator()->stringToProxy(proxy);
cout<<"object: "<<object<<endl;
tienda=TiendaRezAdminPrx::uncheckedCast(object);
}
And I use the next config file for booth
IceBox.ServiceManager.Endpoints=tcp -p 9999
IceBox.Service.Tienda=TiendaService:create
IceBox.DBEnvName.name=TiendaDb
TiendaRez.Proxy=tienda:tcp -h 192.168.0.34 -p 10000
TiendaService.Endpoints=tcp -h 192.168.0.34 -p 10000
Ice.Warn.Connections=1
I run IceBox --Ice.Config=my_config and the server starts ok
but always when i try to conect to the server I received the next exception
Network.cpp:447: Ice::ConnectFailedException:
can same body say me Wha is wron i my case Thanks
connect failed: Connection refused
heare is the code of start method
void
TiendaServiceI::start(const std::string& name, const
Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args, const std::string&)
{
TiendaRezI::_adapter =communicator->createObjectAdapter(name);
ObjectFactoryPtr factory = new TiendaRezFactory();
communicator->addObjectFactory(factory,TiendaRezPersistent::ice_staticId());
TiendaRezI::_evictor = Freeze::createEvictor(communicator,"TiendaDb","tiendaDb");
Ice::Identity idTienda=Ice::stringToIdentity("1");
idTienda.category="tienda";
if (!TiendaRezI::_evictor->hasObject(idTienda))
{
TiendaRezIPtr tienda=new TiendaRezI();
TiendaRezI::_evictor->createObject(idTienda,tienda);
}
TiendaRezI::_evictor->setSize(1000);
}
i creating then an Ice::Application for the client
int Client::run(int argc, char*argv[])
{
Ice::PropertiesPtr properties = communicator()->getProperties();
const char* proxyProperty = "TiendaRez.Proxy";
std::string proxy = properties->getProperty(proxyProperty);
cout<<"Proxy: "<<proxy<<endl;
if(proxy.empty())
{
cerr << argv[0] << ": property `" << proxyProperty << "' not set" << endl;
return EXIT_FAILURE;
}
Ice::ObjectPrx object= communicator()->stringToProxy(proxy);
cout<<"object: "<<object<<endl;
tienda=TiendaRezAdminPrx::uncheckedCast(object);
}
And I use the next config file for booth
IceBox.ServiceManager.Endpoints=tcp -p 9999
IceBox.Service.Tienda=TiendaService:create
IceBox.DBEnvName.name=TiendaDb
TiendaRez.Proxy=tienda:tcp -h 192.168.0.34 -p 10000
TiendaService.Endpoints=tcp -h 192.168.0.34 -p 10000
Ice.Warn.Connections=1
I run IceBox --Ice.Config=my_config and the server starts ok
but always when i try to conect to the server I received the next exception
Network.cpp:447: Ice::ConnectFailedException:
can same body say me Wha is wron i my case Thanks
connect failed: Connection refused
0
Comments
-
Hi,
You are using the following property to define your IceBox service:IceBox.Service.Tienda=TiendaService:create
This means your IceBox service name is Tienda. This is the value of the name parameter passed to your service's start method, which you pass as the name of your object adapter to createObjectAdapter.
Your client cannot connect to your service's object adapter because the endpoints are not configured correctly. The object adapter in this example is looking for a property named Tienda.Endpoints, which is not defined. You have defined TiendaService.Endpoints, but that is not the correct property name.
Also, don't forget to activate your object adapter.
Take care,
- Mark0 -
Thanks Mes
I change the server code and config file
Server code:
void
TiendaServiceI::start(const std::string& name, const
Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args, const std::string&)
{
cout<<"name: "<<name<<endl;
TiendaRezI::_adapter =communicator->createObjectAdapter(name);
ObjectFactoryPtr factory = new TiendaRezFactory();
communicator->addObjectFactory(factory,TiendaRezPersistent::ice_staticId());
TiendaRezI::_evictor = Freeze::createEvictor(communicator,"TiendaDb","tiendaDb");
Freeze::ServantInitializerPtr initTienda=new TiendaRezInitializer;
TiendaRezI::_evictor->installServantInitializer(initTienda);
TiendaRezI::_adapter->addServantLocator(TiendaRezI::_evictor,"tienda");
Ice::Identity idTienda=Ice::stringToIdentity("tienda");
if (!TiendaRezI::_evictor->hasObject(idTienda))
{
TiendaRezIPtr tienda=new TiendaRezI();
TiendaRezI::_evictor->createObject(idTienda,tienda);
}
TiendaRezI::_evictor->setSize(1000);
TiendaRezI::_adapter->activate();
}
My config file:
IceBox.ServiceManager.Endpoints=tcp -p 9999
IceBox.Service.Tienda=TiendaService:create
IceBox.DBEnvName.name=TiendaDb
Tienda.Proxy=tienda:tcp -p 10000
Tienda.Endpoints=tcp -p 10000
Ice.Warn.Connections=1
Ice.Trace.Network=1
Client code:
Ice::ObjectPrx object= communicator()->stringToProxy(proxy);
tienda=TiendaRezAdminPrx::uncheckedCast(object);
almacen=AlmacenAdminPrx::uncheckedCast(tienda->getSrvAlmacen());
Client ouput:
[ ./almacen: Network: tcp connection established
local address = 192.168.0.34:32852
remote address = 192.168.0.34:10000 ]
./almacen: Outgoing.cpp:271: Ice::ObjectNotExistException:
object does not exist
identity: tienda
facet:
operation: getSrvAlmacen
I don' t understand what is wrong in theese case0 -
Hi,
The problem here is that you're registering the evictor as a servant locator for category tienda. This means that it only services requests for objects whose identities contain that category. However, the object you registered with the evictor does not contain this category in its identity, and neither does the proxy your client is using.
The quickest solution is to register the evictor with the "default" category (i.e., use an empty string instead of "tienda" in the call to addServantLocator).
On the other hand, if you really want to use categories, then you will need to correct the identities you are using. See the Ice manual for more information on servant locators and categories.
- Mark0 -
Tank's mes I register the evictor for defautl category and the client connected ok to the service
but if I register the evictor for category tienda and create the object whit tienda category
TiendaRezI::_adapter->addServantLocator(TiendaRezI::_evictor,"tienda");
Ice::Identity idTienda=Ice::stringToIdentity("tienda");
idTienda.category="tienda";
if (!TiendaRezI::_evictor->hasObject(idTienda))
{
TiendaRezIPtr tienda=new TiendaRezI();
TiendaRezI::_evictor->createObject(idTienda,tienda);
}
i received again the object no exist exception
I need to change same thing in config file???0 -
Yes, then you would need to change the Tienda.Proxy property as follows:
Tienda.Proxy=tienda/tienda:tcp -p 10000
- Mark0