Archived
Multiple Clients for one Server (Java)
Comments
-
Could you explain me how run IceStorm Server ?
0 -
I have tried to run icebox --Ice.Config=config.icebox while run IceStorm Publisch and I have the same error
0 -
I have updated my code to .propertyToProxy("TopicManager.Proxy")... and it seems to be working
But I have this exception
Exception in thread "threadClientMetaServeur" java.lang.NullPointerException
at Serveur.MetaServeur$1.run(MetaServeur.java:29)
at java.lang.Thread.run(Thread.java:748)com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args);
com.zeroc.Ice.ObjectPrx obj = communicator.propertyToProxy("TopicManager.Proxy"); com.zeroc.IceStorm.TopicManagerPrx topicManager = com.zeroc.IceStorm.TopicManagerPrx.checkedCast(obj); com.zeroc.IceStorm.TopicPrx topic = null; while(topic == null) { try { topic = topicManager.retrieve("MP3"); } catch(com.zeroc.IceStorm.NoSuchTopic ex) { try { topic = topicManager.create("MP3"); } catch(com.zeroc.IceStorm.TopicExists ex2) { // Another client created the topic. } } }
Its not "an error" but simply an exception caused by no topic exist ?
0 -
I have a problem when I run the subscriber :
Exception in thread "main" com.zeroc.Ice.InitializationException
reason = "object adapter `CommunicateurAdapter' requires configuration"
at com.zeroc.Ice.ObjectAdapterI.(ObjectAdapterI.java:957)
at com.zeroc.IceInternal.ObjectAdapterFactory.createObjectAdapter(ObjectAdapterFactory.java:171)
at com.zeroc.Ice.CommunicatorI.createObjectAdapter(CommunicatorI.java:95)
at Serveur.Serveur.main(Serveur.java:175)String[] params = null; com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(params); com.zeroc.Ice.ObjectPrx obj = communicator.propertyToProxy("TopicManager.Proxy"); com.zeroc.IceStorm.TopicManagerPrx topicManager = com.zeroc.IceStorm.TopicManagerPrx.checkedCast(obj); com.zeroc.Ice.ObjectAdapter adapter = communicator.createObjectAdapter("CommunicateurAdapter"); MP3.Communicateur monitor = new Serveur(args[1]); com.zeroc.Ice.ObjectPrx proxy = adapter.addWithUUID(monitor).ice_oneway(); adapter.activate(); com.zeroc.IceStorm.TopicPrx topic = null; try { topic = topicManager.retrieve("MP3"); java.util.Map<String, String> qos = null; topic.subscribeAndGetPublisher(qos, proxy); } catch(com.zeroc.IceStorm.BadQoS e) { e.printStackTrace(); //return 1;
} catch(com.zeroc.IceStorm.NoSuchTopic ex)
{
// Error! No topic found!
ex.printStackTrace();} catch(com.zeroc.IceStorm.AlreadySubscribed e)
{
// If we're manually setting the subscriber id ignore.
/// if(id == null)
// {
e.printStackTrace();
// return 1;
/* }
else
{*/
System.out.println("reactivating persistent subscriber");
// }
}
catch(com.zeroc.IceStorm.InvalidSubscriber e)
{
e.printStackTrace();
// return 1;
}communicator.waitForShutdown(); topic.unsubscribe(proxy);
0 -
I have updated my Subscriber with createObjectAdapterWithEndpoints("Communicateur.Serveur", "tcp");
it seems to work, its a good solution ?
0 -
I have a java.lang.NullPointerException on retrieve call in Publischer and Subscriber, I known't why
0 -
I think that its a problem because topic musn't be null and the program is blocked in the while...
0 -
Blocked after null pointer exception topicManager.retrieve
0 -
I'm still blocked, could you help me please ?
0 -
Please show the complete stack trace of the exception.
0 -
Exception in thread "threadClientMetaServeur" java.lang.NullPointerException
at Serveur.MetaServeur$1.run(MetaServeur.java:32)
at java.lang.Thread.run(Thread.java:748)Code in attachment
0 -
-
Hi,
It looks like
topicManager
isnull
. This would be the case if you don't correctly provide the Ice configuration on communicator initialization. How do you provide the configuration file to your program? Do you start it with--Ice.Config=config.pub
?See https://doc.zeroc.com/display/Ice37/Communicator+Initialization and https://doc.zeroc.com/display/Ice37/Properties+and+Configuration for additional information on Ice configuration.
Cheers,
Benoit.0 -
Like this : java -cp classes:/usr/sre/java/ice-3.7.0.jar:/usr/share/java/icestorm-3.7.0.jar Serveur.MetaServeur --Ice.Config=config.pub ?
Result :
threadClientMetaServeur (10) : START
Exception in thread "threadClientMetaServeur" com.zeroc.Ice.ConnectFailedException
error = 0
at com.zeroc.IceInternal.OutgoingAsync.waitForResponseOrUserEx(OutgoingAsync.java:146)
at com.zeroc.IceInternal.OutgoingAsync.waitForResponse(OutgoingAsync.java:118)
at com.zeroc.Ice._ObjectPrxI.ice_isA(_ObjectPrxI.java:36)
at com.zeroc.Ice.ObjectPrx._checkedCast(ObjectPrx.java:862)
at com.zeroc.Ice.ObjectPrx._checkedCast(ObjectPrx.java:824)
at com.zeroc.IceStorm.TopicManagerPrx.checkedCast(TopicManagerPrx.java:291)
at Serveur.MetaServeur$1.run(MetaServeur.java:24)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connexion refusée
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at com.zeroc.IceInternal.Network.doFinishConnect(Network.java:541)
at com.zeroc.IceInternal.StreamSocket.connect(StreamSocket.java:96)
at com.zeroc.IceInternal.TcpTransceiver.initialize(TcpTransceiver.java:30)
at com.zeroc.Ice.ConnectionI.initialize(ConnectionI.java:2095)
at com.zeroc.Ice.ConnectionI.message(ConnectionI.java:1078)
at com.zeroc.IceInternal.ThreadPool.run(ThreadPool.java:416)
at com.zeroc.IceInternal.ThreadPool.access$500(ThreadPool.java:12)
at com.zeroc.IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:785)
... 1 more0 -
Could you help please ?
0 -
With Ice.Trace.Network=3, I get more informations :
threadClientMetaServeur (10) : START
-- 09/04/18 15:59:24:402 Network: trying to establish tcp connection to 127.0.0.1:10000
-- 09/04/18 15:59:24:430 Network: failed to establish tcp connection
local address =
remote address = 127.0.0.1:10000
com.zeroc.Ice.ConnectFailedException
error = 0
-- 09/04/18 15:59:24:431 Network: connection to endpoint failed and no more endpoints to try
com.zeroc.Ice.ConnectFailedException
error = 0
-- 09/04/18 15:59:24:432 Network: trying to establish tcp connection to 127.0.0.1:10000
-- 09/04/18 15:59:24:433 Network: failed to establish tcp connection
local address =
remote address = 127.0.0.1:10000
com.zeroc.Ice.ConnectFailedException
error = 0
-- 09/04/18 15:59:24:433 Network: connection to endpoint failed and no more endpoints to try
com.zeroc.Ice.ConnectFailedException
error = 0
Exception in thread "threadClientMetaServeur" com.zeroc.Ice.ConnectFailedException
error = 0
at com.zeroc.IceInternal.OutgoingAsync.waitForResponseOrUserEx(OutgoingAsync.java:146)
at com.zeroc.IceInternal.OutgoingAsync.waitForResponse(OutgoingAsync.java:118)
at com.zeroc.Ice._ObjectPrxI.ice_isA(_ObjectPrxI.java:36)
at com.zeroc.Ice.ObjectPrx._checkedCast(ObjectPrx.java:862)
at com.zeroc.Ice.ObjectPrx._checkedCast(ObjectPrx.java:824)
at com.zeroc.IceStorm.TopicManagerPrx.checkedCast(TopicManagerPrx.java:291)
at Serveur.MetaServeur$1.run(MetaServeur.java:24)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connexion refusée
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at com.zeroc.IceInternal.Network.doFinishConnect(Network.java:541)
at com.zeroc.IceInternal.StreamSocket.connect(StreamSocket.java:96)
at com.zeroc.IceInternal.TcpTransceiver.initialize(TcpTransceiver.java:30)
at com.zeroc.Ice.ConnectionI.initialize(ConnectionI.java:2095)
at com.zeroc.Ice.ConnectionI.message(ConnectionI.java:1078)
at com.zeroc.IceInternal.ThreadPool.run(ThreadPool.java:416)
at com.zeroc.IceInternal.ThreadPool.access$500(ThreadPool.java:12)
at com.zeroc.IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:785)
... 1 more0 -
I have updated my config file to :
#
This property is used by the clients to connect to IceStorm.
#
TopicManager.Proxy=DemoIceStorm/TopicManager:default -h localhost -p 10000
ClientMetaServeur.Endpoints=tcp -p 10015
Ice.Default.Host=localhost
Ice.Warn.Connections=1
#Network Tracing
#
0 = no network tracing
1 = trace connection establishment and closure
2 = like 1, but more detailed
3 = like 2, but also trace data transfer
#
Ice.Trace.Network=3#
IceMX configuration.
#
Ice.Admin.Endpoints=tcp -h localhost -p 10003
Ice.Admin.InstanceName=publisher
IceMX.Metrics.Debug.GroupBy=id
IceMX.Metrics.ByParent.GroupBy=parentIt can be correct... ?
Result :
Result (no exception, trafic seems to be good) :
threadClientMetaServeur (10) : START
-- 09/04/18 16:20:18:346 Network: attempting to bind to tcp socket 127.0.0.1:10015
-- 09/04/18 16:20:18:347 Network: listening for tcp connections
local address = 127.0.0.1:10015
-- 09/04/18 16:20:18:349 Network: published endpoints for object adapter `ClientMetaServeur':
tcp -h localhost -p 10015 -t 60000
-- 09/04/18 16:20:18:351 Network: accepting tcp connections at 127.0.0.1:10015
-- 09/04/18 16:20:18:412 Network: trying to establish tcp connection to 127.0.0.1:10000
-- 09/04/18 16:20:18:429 Network: received 14 of 14 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:430 Network: established tcp connection
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:432 Network: sent 86 of 86 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:432 Network: received 14 of 14 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:432 Network: received 12 of 12 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
PAsse avant retriwe TOPIC
-- 09/04/18 16:20:18:436 Network: sent 66 of 66 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:436 Network: received 14 of 14 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:436 Network: received 69 of 69 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
PAsse apres retriwe TOPIC
-- 09/04/18 16:20:18:440 Network: sent 63 of 63 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:440 Network: received 14 of 14 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:20:18:440 Network: received 94 of 94 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:21:48:436 Network: sent 14 of 14 bytes via tcp
local address = 127.0.0.1:52252
remote address = 127.0.0.1:10000
-- 09/04/18 16:21:48:436 Network: closed tcp connection
local address = 127.0.0.1:52252
remote address = 127.0.0.1:100000 -
However, I have a problem with My IceStorm Subscriber / Ice Client (in the same class, with thread) :
java -cp classes:/usr/sre/java/ice-3.7.0.jar:/usr/share/java/icestorm-3.7.0.jar Serveur.Serveur Serveur1 --Ice.Config=config.pub
Result :
Exception in thread "main" com.zeroc.Ice.InitializationException
reason = "object adapter `Communicateur.Subscriber' requires configuration"
at com.zeroc.Ice.ObjectAdapterI.(ObjectAdapterI.java:957)
at com.zeroc.IceInternal.ObjectAdapterFactory.createObjectAdapter(ObjectAdapterFactory.java:171)
at com.zeroc.Ice.CommunicatorI.createObjectAdapter(CommunicatorI.java:95)
at Serveur.Serveur.main(Serveur.java:175)And since I have changed my config.pub to have a working code (same file for IceStorm Publischer / Ice Server ; IceStorm Susbcriber / Ice Client) I have this warning when I run IceStorm Publischer : 09/04/18 16:55:55:056 warning: main: found unknown properties for object adapter `ClientMetaServeur':
ClientMetaServeur.ProxyClasses code and config file in attachment
0 -
I'm still blocked, could you help please ?
0 -
Hi,
The exception are you getting indicates that the object adapter named
Communicateur.Subscriber' isn't configured. An object adapter needs at least one property to be set for its configuration, the
.Endpoints` property. See https://doc.zeroc.com/display/Ice37/Creating+an+Object+Adapter for information on how to create an object adapter.For example, adding the property setting
Communicateur.Subscriber.Endpoints=tcp
to your configuration file, you allow the adapter creation to succeed. The object adapter will listen on a random TCP port on all the network interfaces provided by your host.See https://doc.zeroc.com/display/Ice37/Object+Adapter+Endpoints for additional information on object adapter endpoints.
Cheers,
Benoit.0 -
The property Communicateur.Subscriber.Endpoints=tcp:udp is already defined in the config file (in
Serveur.java.zip in one of my previous posts)0 -
Hi,
I recommend taking a bit of time to understand how Ice configuration works. Again, here are the links to the documentation in our manual:
- https://doc.zeroc.com/display/Ice37/Communicator+Initialization
- https://doc.zeroc.com/display/Ice37/Properties+and+Configuration
The command line option
--Ice.Config=config.pub
specifies the property file to be loaded by theIce.Communicator
on Ice initialization. The Java runtime provides the command line arguments into theargs
argument of themain
method. If you don't provide theargs
argument to the communicator initialization method, Ice won't load and won't use the configuration file.You need to provide the
args
value to the communicator initialization if you want the communicator property set to contain the propertyCommunicateur.Subscriber.Endpoints
used to configure the object adapter.Cheers,
Benoit.0 -
Thanks, my backend part works, but I'm trying to create an Ice Client on Android (with Android Studio) and I don't find how include slice2java generated into the Android Studio Project.
Consequently, in my Ice Client class
public class ClientServeur {
public ClientServeur(String message) { String[] params = null; try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(params)) { com.zeroc.Ice.ObjectPrx base = communicator.stringToProxy("clientmetaserveur:default -p 10045"); MP3.ClientMetaServeurPrx printer = MP3.ClientMetaServeurPrx.checkedCast(base); if(printer == null) { throw new Error("Invalid proxy"); } printer.setReponse(message); } }
}
MP3.ClientMetaServeurPrx can't be found
0 -
Hi,
I recommend to checkout our Android demos and release notes for some examples on how to Android projects are setup for Ice.
Cheers,
Benoit.0