Archived

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

Glacier2 and Python

Hi everyone

For the paste couple of days, I have been trying to make a connection to a Ice server behind a Glacier2 router.
I have successfully done this in PHP, but now I am trying to get this to work in Python with no luck, I have looked at the python + glacier2 demos, but not with much luck.

Currently I have this code, but it gives me an "Ice.ConnectionRefusedException" error when I try it.
import Ice, Glacier2

Ice.loadSlice('Murmur.ice')
ice = Ice.initialize()
import Murmur
defaultRouter = ice.stringToProxy("PeberCPGlacier2/router:tcp -p 4063 -h 192.168.1.20")
router = Glacier2.RouterPrx.checkedCast(defaultRouter)
router.createSession('dev', 'devhest');
prx = ice.stringToProxy("Meta:tcp -p 6502 -h 127.0.0.1")
meta = Murmur.MetaPrx.checkedCast(prx)
meta.getVersion()

From my logic I am missing something in between, since when I used Ice on PHP, I had to define the router on every connection. But from the python demo, there is none on the Client, at least not from what I can see.
Any suggestions?

Comments

  • matthew
    matthew NL, Canada
    It looks to me like the router isn't being set on the proxy. You need to either set the default router on the communicator (in which case ever proxy created by that communicator gets the router set implicitly) or you need to set the router on the proxy manually, by calling ice_router.
      meta = Murmur.MetaPrx.checkedCast(prx.ice_router(defaultRouter));
    

    I recommend using a default router as this is much simpler and less error prone.
  • xdm
    xdm La Coruña, Spain
    Hi Mads,

    If you look at the python demo, in the client configuration file
    #
    # The proxy to the Glacier2 router for all outgoing connections. This
    # must match the value of Glacier2.Client.Endpoints in config.glacier2.
    #
    Ice.Default.Router=DemoGlacier2/router:ssl -p 4064 -h 127.0.0.1
    

    When Ice.Default.Router property is set all proxies are routed throw the default router, i suspect that you are not setting this property, note that you can also set the router used by a proxy calling ice_router, this will return a new proxy with the router set to the proxy you passed in.

    Regards,
    José
  • Hi all,

    sorry for the delay on the reply, but from the answers I got it working, thank you very much! :)