Archived

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

[Proxy] How check if proxy cached is valid

Hi,

In my server application I cached the proxy of node A in order to at future use a remote method from it after do an operation with node B. How can I check if the proxy cached from node A is valid?

If I try use a remote operation of node A and it was disconnected ... my server will be frozen, and it will be active again when the node A get connection again.

I try to do "ice_ping" from my server before call my remote operation, but the result is the same, obviously.

Thank you in advance,

Best regards,

Note: My server is written in python

Comments

  • benoit
    benoit Rennes, France
    Hi,

    What do you mean by "valid" for a proxy? A proxy object might not have an underlying Ice connection to the server, it might not point to a existent Ice object but there isn't really such a thing as an invalid proxy object.

    An invocation on a proxy will trigger the connection establishment to the server if the connection isn't already established. The connection establishment shouldn't block forever. Is your problem that the call on the proxy that points to an Ice object on node A hangs when the connection isn't already established?

    If that's the case, it's difficult to say why this occurs without more information. Could you enable network and protocol tracing and post the traces? You can enable protocol/network tracing with Ice.Trace.Network=2 and Ice.Trace.Protocol=1.

    Cheers,
    Benoit.
  • Hi,

    Ok, I try to give you more information about the problem.

    I have a slice A, a node that implements slice A, and a server. The node A give his proxy to the server, and if server need use a method defined at slice A for the node A, it calls the needed method.

    Steps:
    * Node A give his proxy to the server
    * Server has the proxy of node A
    * Node A is disconnected from network
    * Server calls a method of node A through his proxy.
    * Server is frozen

    I would like can check the status of a proxy of node A in the server. Can I do this?

    Best regards,
  • benoit
    benoit Rennes, France
    I suppose the call doesn't really hang forever but hangs for a long time because the machine running "node A" is inaccessible.

    There's no way to figure out if a machine is accessible or not before calling on a proxy. The only way to figure this out is to make the remote invocation. If you don't want the connection establishment to hang for too long, you should set a timeout on the endpoint (with the -t endpoint option) or set Ice.Override.ConnectTimeout.

    ​See https://doc.zeroc.com/display/Ice36/Connection+Timeouts for more information on connection timeouts.

    You could for example set Ice.Override.ConnectTimeout=5000 to ensure the connection establishment doesn't take longer than 5 seconds.

    You could also consider using AMI (begin_ice_ping for example) instead of regular synchronous calls if you don't want to block the server thread while performing the remove invocation.

  • Hi,

    Thank you for your fast reponse.

    In this case, we want to not use AMI for some reasons, but, we had not established the property Ice.Override.ConnectionTimeout, however with this property the problem persist, but I added the overriden property Ice.Override.Timeout to X milliseconds and this solve the problem ... but at now, I have a new doubt, ¿Could be a problem 4 seconds for this property for the general use of ZeroC ICE?

    Best regards,
  • benoit
    benoit Rennes, France
    Hi,

    There's no Ice.Override.ConnectionTimeout property, it's [FONT=courier new, courier, monospace]Ice.Override.ConnectTimeout.[/FONT][FONT=arial, helvetica, sans-serif] Did you perhaps misspell the property?[/FONT]

    [FONT=arial, helvetica, sans-serif]The [/FONT]Ice.Override.Timeout[FONT=arial, helvetica, sans-serif] setting will apply to all the Ice connections. With Ice versions < 3.6, setting the timeout to a small value could be an issue if you have invocations which take longer than the timeout to dispatch. The invocation will fail with a timeout exception and the connection will be closed. This is no longer the case with Ice 3.6 where we introduced invocation timeouts (see [/FONT]Invocation Timeouts). Which Ice version do you use?

    If you use Ice < 3.6, instead of setting Ice.Override.Timeout you could set the timeout on the proxy object with the ice_timeout(v) method or set the timeout on the proxy endpoint (if the proxy has been created by the server object adapter, you can also set the timeout on the object adapter endpoint with the -t <v> endpoint option).

    Cheers,
    Benoit.
  • Hi,

    Yes, I was wrong with the property, although I have used the Ice.Override.ConnectTimeout and the result is the same, it doesn't work. Before I asked you some days ago, I tried with the MyProxy.ice_timeout() but it didn't work also.

    I don't have any operation (in normal conditions) that needs more than 4 seconds for example, but I don't like override globally this property.

    Do I need override another property in order to set programmatically proxy.ice_timeout(v)?

    I'm using ZeroC ICE 3.5.0 version.
  • benoit
    benoit Rennes, France
    Hi,

    No other properties should be needed for ice_timeout(v) to work. It's not clear why it's not working for you. Did you make sure to re-assign the proxy? Proxies are immutable objects and this method is therefore a factory method that should be used as shown below:
    proxy = proxy.ice_timeout(v);
    

    I suppose Ice.Override.ConnectTimeout doesn't work because the connection is already established but the network stack didn't detect that the peer is no longer accessible. It would be good to ensure this is the case (you could enable network/protocol tracing to confirm this).

    Another option to setting the timeout programmatically is to set the -t <value> option on the tcp endpoint of the server's object adapter running on node A (e.g.: [FONT=courier new, courier, monospace]MyAdapter.Endpoints=tcp -t 5000 -h 192.168.15.4 -p 12345[/FONT][FONT=arial, helvetica, sans-serif]). With this setting all the proxies created by the object adapter will have a timeout set.[/FONT]

    Cheers,
    Benoit.
  • Hi,

    I have tried again with no property overridden at configuration and using the "prx = prx.ice_timout(milliseconds)" method, and the server is working fine.

    Thank your very much for your support.

    Best regards,