Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-04-2006
rc_hz rc_hz is offline
Registered User
 
Name: Eric RC
Organization: www.genband.com
Project: No project yet
 
Join Date: Jul 2004
Location: Hangzhou, China
Posts: 189
Send a message via MSN to rc_hz
-->
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.
  ...
In my view, since these factory methods return new proxy instances, these new proxies should manage their own connections (establish a new connection, reuse an existing connection, etc) at their first invocation, which don't need to have relations with their previous proxy.
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
At timeD, the invocation on new proxies all gets an exception of CloseConnectionException. It seems that they all reuse the connection of "twoway" proxy instead of establish a new connection. Is it strange ?

Thank you!
__________________
Eric RC
www.genband.com (telecommunication)
I like ICE (Ice for C++/Java/Python)
Reply With Quote
  #2 (permalink)  
Old 09-04-2006
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
Connection reuse is intended behavior. I do not find this behavior strange, but logical. If you do not wish to reuse connections, use ice_connectionId(). Please see the manual, section "34.3.2 Connection Reuse" for details.
Reply With Quote
  #3 (permalink)  
Old 09-04-2006
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,088
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"));
Pressing 't' sends twoway, '1' uses p1, etc. I modified the configuration to set Ice.RetryIntervals to 1. Then I ran the server and client with network tracing so I could see what connections are being used. The result is as expected.

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 ]
==>
I don't know why my results differ to yours. If you want me to look further please give me much more information. Ice version, platform, JDK version and a complete self-contained compilable demo.
Reply With Quote
  #4 (permalink)  
Old 09-05-2006
rc_hz rc_hz is offline
Registered User
 
Name: Eric RC
Organization: www.genband.com
Project: No project yet
 
Join Date: Jul 2004
Location: Hangzhou, China
Posts: 189
Send a message via MSN to rc_hz
-->
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(...));
So the new proxies returned from these proxy factory methods are also fixed connection proxies which use the same connection as "twoway". If the connection is lost, these new proxies can not work either.

The attachment is a self-contained example. (JDK5.0, Ice3.1, Windows XP SP2).

Thanks again!
__________________
Eric RC
www.genband.com (telecommunication)
I like ICE (Ice for C++/Java/Python)
Reply With Quote
  #5 (permalink)  
Old 09-05-2006
rc_hz rc_hz is offline
Registered User
 
Name: Eric RC
Organization: www.genband.com
Project: No project yet
 
Join Date: Jul 2004
Location: Hangzhou, China
Posts: 189
Send a message via MSN to rc_hz
-->
This is the attachment.
Attached Files
File Type: zip hello.zip (25.3 KB, 5 views)
__________________
Eric RC
www.genband.com (telecommunication)
I like ICE (Ice for C++/Java/Python)
Reply With Quote
  #6 (permalink)  
Old 09-05-2006
rc_hz rc_hz is offline
Registered User
 
Name: Eric RC
Organization: www.genband.com
Project: No project yet
 
Join Date: Jul 2004
Location: Hangzhou, China
Posts: 189
Send a message via MSN to rc_hz
-->
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();
        }
    }
The same are ice_connectionId and ice_secure.
__________________
Eric RC
www.genband.com (telecommunication)
I like ICE (Ice for C++/Java/Python)

Last edited by rc_hz : 09-05-2006 at 07:50 AM.
Reply With Quote
  #7 (permalink)  
Old 09-05-2006
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
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.
Reply With Quote
  #8 (permalink)  
Old 09-05-2006
rc_hz rc_hz is offline
Registered User
 
Name: Eric RC
Organization: www.genband.com
Project: No project yet
 
Join Date: Jul 2004
Location: Hangzhou, China
Posts: 189
Send a message via MSN to rc_hz
-->
Quote:
Originally Posted by marc
...I guess an exception would be more appropriate instead of silently ignoring the request...
I think so
__________________
Eric RC
www.genband.com (telecommunication)
I like ICE (Ice for C++/Java/Python)
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -4. The time now is 12:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.