Home Help Center

IceStorm & Glacier2

xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
I trying to make a client that receive events from and IceStorm that is behind a Glacier2, my problem is that event seems to be published ok in IceStorm but they don't arrive at client side.

i paste the relevant code i use here

any ideas what is wrong I think is a config problem because code is similar of your Ice examples but i cand found where is my error

Lisetener interface
module Oz
{
	module Base
	{
		interface EventListener
		{	
			idempotent void
			notify(
				Event e);
		};
	};
};

Server Code for send events
void
Oz::Base::OnRezI::eMit(
	const Oz::Base::EventPtr& e,
	const Ice::Current& current)
{
	IceUtil::RWRecMutex::WLock sync(*this);
	Ice::CommunicatorPtr ic = current.adapter->getCommunicator();
	string topicName = "topic/"+ic->identityToString(id);
	IceStorm::TopicPrx topicPx;
	try
	{
		topicPx = Oz::Base::OnRezI::topicManager->retrieve(topicName);
	}
	catch(const IceStorm::NoSuchTopic e)
	{
		try
		{
			topicPx = Oz::Base::OnRezI::topicManager->create(topicName);
		}
		catch(const Ice::Exception& ice_e)
		{
			std::cout<<"file "<<__FILE__<<" line "<<__LINE__<<" "<<ice_e<<std::endl;
		}
	}
	assert(topicPx);
	
	Ice::ObjectPrx obj = topicPx->getPublisher();
	if(!obj->ice_isDatagram())
	{
		obj = obj->ice_oneway();
	}
	Oz::Base::EventListenerPrx listener = EventListenerPrx::uncheckedCast(obj);
	listener->notify(e);
}

client code to connect Glacier2 and create is objectAdapter to receive events
void
Oz::Ui::HydraModel::login(
	const std::string& user,
	const std::string& password)
{
	try
	{
		_sessionPx = Oz::App::AppSessionPrx::uncheckedCast(
			HydraModel::App()->getRouter()->createSession(user,password));

		/**
		 *
		 */

		_adapter = HydraModel::App()->communicator()->createObjectAdapter("Ui.Client");
		_adapter->activate();

		emit loginSuccess();
	}
	catch(const Glacier2::PermissionDeniedException& glacier2_e)
	{
		std::ostringstream os;
		os <<" reason: "<<glacier2_e.reason;
		QMessageBox::warning(0, "Error", os.str().c_str());
	}
}

client code for subscrive
Oz::Ui::DomainListModel::DomainListModel(
	const DomainServerManagerPrx& _domainServerManagerPx,
	QObject *parent)
	:QAbstractListModel(parent)
{
	this->_domainServerManagerPx = _domainServerManagerPx;
	_itemsPerPage = 20;
	_page = 0;

	uiEventListener = new UiEventListener(this);

	connect(
		uiEventListener.get(),
		SIGNAL(modelUpdated()),
		this,
		SLOT(update()));

	Ice::Identity uiEventListenerId;
	uiEventListenerId.name = IceUtil::generateUUID();
	uiEventListenerId.category = HydraModel::Model()->getSession()->getId().category;
	
	eventListenerPx = Oz::Base::EventListenerPrx::uncheckedCast(
		HydraModel::Model()->getAdapter()->add(uiEventListener,uiEventListenerId));

	_domainServerManagerPx->setUserEventListener(eventListenerPx);
}

client EventListener implementation
Oz::Ui::UiEventListener::UiEventListener(QObject* parent)
	:QObject(parent)
{

}

void
Oz::Ui::UiEventListener::notify(
	const EventPtr& e,
	const Ice::Current& current)
{
	std::cout<<"UiEventListener notify: "<<e->getName()<<std::endl;
	emit modelUpdated();
}
glacier2 config
Ice.Default.Locator=IceGrid/Locator:tcp -h 127.0.0.1 -p 14000
Ice.StdOut=/var/log/hydra/glacier2router_access.log
Ice.StdErr=/var/log/hydra/glacier2router_error.log
Glacier2.InstanceName=Glacier2
Glacier2.Client.Endpoints=tcp -p 10005 -h 127.0.0.1
Glacier2.AddUserToAllowCategories=0
Glacier2.Server.Endpoints=tcp -h 127.0.0.1
Glacier2.SessionManager=SessionService-SessionManager
Glacier2.PermissionsVerifier=SessionService-permission-verifier
Glacier2.SessionTimeout=1800
Ice.ThreadPool.Client.StackSize=8
Ice.ThreadPool.Server.StackSize=8
Ice.MessageSizeMax=2048
Glacier2.Server.Buffered=0
Glacier2.Client.Buffered=0

client config
Ice.Default.Router = Glacier2/router:tcp -h 127.0.0.1 -p 10005
Ice.MessageSizeMax = 2048
Ice.ACM.Client=0
Ice.ACM.Server=0
Ui.Client.Router = Glacier2/router:tcp -h 127.0.0.1 -p 10005
Ui.Client.Endpoints=
Ice.ACM.Client=0
Ice.ACM.Server=0
Ice.MonitorConnections=60
Ice.RetryIntervals=-1
Ice.Trace.Network=1
Ice.Trace.Protocol=1
Ice.Warn.Connections=1
[ HydraIceStorm-IceStorm: Network: accepted tcp connection
  local address = 192.168.0.105:4527
  remote address = 192.168.0.105:4395 ]
[ HydraIceStorm-IceStorm: Protocol: sending validate connection
  message type = 3 (validate connection)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 14 ]
[ HydraIceStorm-IceStorm: Protocol: received request
  message type = 0 (request)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 88
  request id = 1
  identity = IceStorm/TopicManager
  facet =
  operation = retrieve
  mode = 1 (nonmutating)
  context =  ]
[ HydraIceStorm-IceStorm: Protocol: sending reply
  message type = 2 (reply)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 105
  request id = 1
  reply status = 0 (ok) ]
[ HydraIceStorm-IceStorm: Protocol: received request
  message type = 0 (request)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 71
  request id = 2
  identity = topic\/DomainServer\/Alcompleto
  facet =
  operation = getPublisher
  mode = 1 (nonmutating)
  context =  ]
[ HydraIceStorm-IceStorm: Protocol: sending reply
  message type = 2 (reply)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 107
  request id = 2
  reply status = 0 (ok) ]
[ HydraIceStorm-IceStorm: Network: accepted tcp connection
  local address = 192.168.0.105:4845
  remote address = 192.168.0.105:1715 ]
[ HydraIceStorm-IceStorm: Protocol: sending validate connection
  message type = 3 (validate connection)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 14 ]
[ HydraIceStorm-IceStorm: Protocol: received request
  message type = 0 (request)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 163
  request id = 0 (oneway)
  identity = topic\/DomainServer\/Alcompleto/publish
  facet =
  operation = notify
  mode = 2 (idempotent)
  context =  ]
[ HydraIceStorm-IceStorm: Network: tcp connection established
  local address = 127.0.0.1:2666
  remote address = 127.0.0.1:3295 ]
[ HydraIceStorm-IceStorm: Protocol: received validate connection
  message type = 3 (validate connection)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 14 ]
[ HydraIceStorm-IceStorm: Protocol: sending batch request
  message type = 1 (batch request)
  compression status = 0 (not compressed; do not compress response, if any)
  message size = 340
  number of requests = 2
  request #0:
  identity = [email protected]/D00C1440-A594-4A70-AF51-0191787FDC8A
  facet =
  operation = notify
  mode = 2 (idempotent)
  context =
  request #1:
  identity = [email protected]/6C818953-FC74-4F7D-A127-CAE8B46ADD23
  facet =
  operation = notify
  mode = 2 (idempotent)
  context =  ]

thanks in advance

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    What does the HydraModel::Model()->getSession()->getId() method return? From the traces, it looks like it's the user id of the session ("[email protected]"). This would be wrong and it's probably the reason why Glacier2 doesn't forward the requests from IceStorm to your client.

    The category of your listener object should be set to the string returned by Glacier2::Router::getCategoryForClient(). See the demo/Glacier2/callback demo for an example.

    Cheers,
    Benoit.
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Thanks Benoit
    i made the changes that you suggest and all is working as expected. :D
Sign In or Register to comment.