Archived

This forum has been archived. Please start a new discussion on GitHub.

IceStorm problems with "propertyToProxy"

Hello,

I am trying to use IceStorm with configuration files.
 class myClass : virtual public ::Ice::Application
{
  private:
         class subscriber;

         class  publisher;
  public:  
           myclass()
          {
             theSubscriber = new subscriber();
             thePublicher = new publisher();
           }
}

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    You have not given us much information. What exactly is the problem you are having? Also, always include your os/compiler/Ice version.
  • IceStorm problems with "propertyToProxy"

    I use Ice 3.3
     class myClass : virtual public ::Ice::Application
    {
      private:
             class subscriber;  
             class  publisher;
      public:  
               myclass()
              {
                 theSubscriber = new subscriber();
                 thePublicher = new publisher();
               }
              
              int run (int argc, char argv[]);
    }
    
    

    the function run is like this:
    
    int myClass::run (int argc, char argv[])
    {
    try
    	{
    	::Ice::ObjectAdapterPtr adapter;
    
     	::IceStorm::TopicPrx topic subscriber_topic;
    	::IceStorm::TopicPrx topic_publisher_topic;
    
    
    [B]	[B]::Ice::ObjectPrx obj = ic->propertyToProxy("TopicManager.Proxy");[/B]
    	[COLOR="Green"]
          //before I had this and it worked : [/COLOR]
    
    [COLOR="Red"]//::Ice::ObjectPrx obj = ic->stringToProxy("DemoIceStorm/TopicManager:tcp -h xxx.xxx.xxx.87 -p 10000");[/COLOR]
    	
        [COLOR="Green"] // When I print the value of obj in the screen it is empty[/COLOR][/B]
    
           std::cout<<"obj = "<<obj<<std::endl;
    
     
    	::IceStorm::TopicManagerPrx manager = ::IceStorm::TopicManagerPrx::checkedCast(obj);
        if(!manager)
        {
            std::cerr << "ERROR : invalid proxy" << std::endl;  
        }
    
    
        //
        // Retrieve the topic.
        //
           .............
    
        // Get the topic's publisher object, and create a Clock proxy with
        // the mode specified as an argument of this application.
        //
         .....................
    
        //
        // Add a Servant for the Ice Object.
        //
    
        ............................
    	catch(const char* err)
    	{
    		std::cerr<<"error: "<<err<<std::endl;
    		return EXIT_FAILURE;
    	}
    }
    
    

    I use the following config file
    
    
    #------------------------------------------------------------------
    #		IceStorm Configuration Properties
    #------------------------------------------------------------------
    
    IceStorm.InstanceName=DemoIceStorm
    
    #
    # This property defines the endpoints on which the topic
    # publisher objects listen. If you want to federate
    # IceStorm instances this must run on a fixed port (or use
    # IceGrid).
    #
    
    #
    # This property is used to configure the endpoints of the Audio
    # subscriber adapter.
    #
    
    Audio.Subscriber.Endpoints=tcp:udp
    
    #
    # This property is used by the clients to connect to IceStorm.
    #
    
    [B]TopicManager.Proxy=DemoIceStorm/TopicManager:tcp -h xxx.xxx.xxx.87 -p 10000[/B]
    
    
    

    thanks for the help.
  • dwayne
    dwayne St. John's, Newfoundland
    Most likely you are not telling your application to load the config file. You need to either pass it on the command line using "--Ice.Config=myconfig" or in code you could pass to Application::main(). For example
        myclass mc = new myclass();
        myclass.main(argc, argv, "myconfig");
    
  • In fact I am passing the config file just like you just told me.

    The only difference I find cheking the clock example is the "ic" parameter. I see in the example "communicator()->propertyToProxy("TopicManager.Proxy")"

    Could this be a problem?
  • dwayne
    dwayne St. John's, Newfoundland
    What is ic? The Application class creates the communicator for you, which you can access via the communicator() method. Are you creating a second communicator? If that is the case then it is very unlikely that it is needed, as well as it being the cause of your issue. The config is read by the Application communicator but not by the communicator you are using.
  • Solved

    Ok it works!!

    I had to change my Ice::CommunicatorPtr.


    Instead of
    Ice::CommunicatorPtr ic
    

    I had to use
    communicator()  //from Ice::Application
    
    


    Thanks for the quick help!! :)