|
|
|
|||||
|
Question about proxy's factory methods.
As Ice Manual says:
Code:
Proxy's methods can be categorized as follows: ... Factory: methods that return new proxy instances configured with different features. ... However , in the example: Code:
//we configure the Client: Ice.RetryIntervals=-1
//timeA: Client get a proxy and establish a connection
HelloPrx twoway = HelloPrxHelper.checkedCast(communicator().stringToProxy("Hello"));
twoway.ice_ping();
twoway.sayHello();
//timeB: Server close the connection gracefully.
...
//timeC: Client get a new proxy with the help of factory methods:
HelloPrx another1 = HelloPrxHelper.uncheckedCast(twoway.ice_compress(false));
HelloPrx another2 = HelloPrxHelper.uncheckedCast(twoway.ice_timeout(-1));
HelloPrx another3 = HelloPrxHelper.uncheckedCast(twoway.ice_timeout(1000));
HelloPrx another4 = HelloPrxHelper.uncheckedCast(twoway.ice_secure(true));
HelloPrx another5 = HelloPrxHelper.uncheckedCast(twoway.ice_connectionId("JustForTest"));
//timeD: get a invocation from these new proxies:
anotherX.ice_ping(); //X=1,2,3,4,5
Thank you! |
|
||||||
|
Hi Eric,
I've been looking into your problem and I cannot duplicate it. What I expect to happen is that twoway, another1 and another2 will share a connection. another3, 4 & 5 will all get their own connections (as described in the Ice manual). You should not get an exception because the connection is closed gracefully by the server. I modified the hello demo that comes with the Ice for java distribution more or less as you do above: Code:
HelloPrx twoway = HelloPrxHelper.checkedCast(
communicator().stringToProxy(proxy).ice_twoway().ice_timeout(-1).ice_secure(false));
if(twoway == null)
{
System.err.println("invalid proxy");
return 1;
}
HelloPrx p1 = HelloPrxHelper.uncheckedCast(twoway.ice_compress(false));
HelloPrx p2 = HelloPrxHelper.uncheckedCast(twoway.ice_timeout(-1));
HelloPrx p3 = HelloPrxHelper.uncheckedCast(twoway.ice_timeout(1000));
HelloPrx p4 = HelloPrxHelper.uncheckedCast(twoway.ice_secure(true));
HelloPrx p5 = HelloPrxHelper.uncheckedCast(twoway.ice_connectionId("JustForTest"));
Code:
t [ Network: tcp connection established local address = 127.0.0.1:50614 remote address = 127.0.0.1:10000 ] ==> [ Network: closing tcp connection local address = 127.0.0.1:50614 remote address = 127.0.0.1:10000 ] 1 [ Network: tcp connection established local address = 127.0.0.1:50615 remote address = 127.0.0.1:10000 ] ==> 2 ==> 3 [ Network: tcp connection established local address = 127.0.0.1:50616 remote address = 127.0.0.1:10000 ] ==> 4 [ Network: ssl connection established local address = 192.168.1.107:50617 remote address = 192.168.1.107:10001 ] [ Network: ssl connection established local address = 192.168.1.107:50617 remote address = 192.168.1.107:10001 ] ==> 5 [ Network: tcp connection established local address = 192.168.1.107:50618 remote address = 192.168.1.107:10000 ] ==> |
|
|||||
|
Thanks, matthew and Marc.
I have found what's wrong with my code. In my code, the "twoway" proxy is a fixed connection proxy as following: Code:
twoway = HelloPrxHelper.uncheckedCast(
orig.ice_getConnection().createProxy(...));
The attachment is a self-contained example. (JDK5.0, Ice3.1, Windows XP SP2). Thanks again! |
|
|||||
|
This is the attachment.
|
|
|||||
|
Further test shows that these proxy factory methods(ice_timeout/ice_connectionId/ice_secure) have no impact on a fixed connection. For example(Change a little the code in the above attachment) :
Code:
// -- Client.java -- // 1.a common proxy HelloPrx original = HelloPrxHelper.checkedCast( communicator().stringToProxy(proxy)); // 2.a fixed connection proxy HelloPrx twoway = HelloPrxHelper.uncheckedCast( original.ice_getConnection().createProxy(original.ice_getIdentity())); // 3. twoway.sayHello(); Thread.sleep(3000); // 4. get new proxies by proxy factory methods HelloPrx another = HelloPrxHelper.uncheckedCast(twoway.ice_timeout(1000)); // 5. invocate these new proxies and get CloseConnectionException exception // Attention: the invocation doest not timeout! another.sayHello(); Code:
// -- HelloI.java --
sayHello(Ice.Current current)
{
try
{
//current.con.close(false);
Thread.sleep(3000);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
Last edited by rc_hz : 09-05-2006 at 07:50 AM. |
|
||||||
|
You are correct, once a proxy has a fixed connection, it will never change, regardless of whether you change the timeout, switch it to secure, etc. I guess an exception would be more appropriate instead of silently ignoring the request. We will put this on our todo list.
|
|
|||||
|
Quote:
![]() |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| specifying proxy's locator | n2503v | Help Center | 2 | 01-31-2006 10:54 PM |
| Add methods to a Java sample ???? | surfer | Help Center | 8 | 01-18-2006 08:23 PM |
| About the Proxy's lifetime | level | Help Center | 2 | 11-22-2005 09:34 AM |
| Local or server private methods | dashie | Help Center | 6 | 12-22-2004 03:31 AM |
| Object Factory | enzo | Help Center | 2 | 03-17-2004 02:29 PM |