Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dsdp-tcf-dev] Handling errors when opening a channel

Eugene,

Thanks, that makes sense. But now I'm curious about the role of the two
channel listeners. It seems like Protocol.ChannelOpenListener tells you
about any new channel when it is opened, and then I suppose you could add a
IChannel.IChannelListener to the channels you are interested in to find out
when they close down, but it would seem simpler to have a
Protocol.ChannelCloseListener as well.

Our code originally looked like your example but I wondered if
IChannel.IChannelListener.onChannelOpened could be reliable since opening a
channel is asynchronous and might happen before the listener could be
installed.

The test case I'm working on involves having an agent shut down but the
client attempts to connect to it before the LocatorService's peer list is
updated. Is there a way to either force the peer list to refresh or for the
agent to provoke this when it shuts down?

Thanks - Ken

> From: "ext Tarassov, Eugene" <eugene.tarassov@xxxxxxxxxxxxx>
> Reply-To: DSDP TCF dev list <dsdp-tcf-dev@xxxxxxxxxxx>
> Date: Fri, 1 May 2009 00:30:02 +0200
> To: DSDP TCF dev list <dsdp-tcf-dev@xxxxxxxxxxx>
> Subject: RE: [dsdp-tcf-dev] Handling errors when opening a channel
> 
> Hi Ken,
> 
> The code is supposed to look like this:
> 
> channel = peer.openChannel();
> channel.addChannelListener(new IChannel.IChannelListener() {
> 
>   public void onChannelOpened() {
>   }
> 
>   public void congestionLevel(int level) {
>   }
> 
>   public void onChannelClosed(Throwable error) {
> 
>     ... handle Connection refused (and all other errors) here ...
> 
>   }
> });
> 
> 
> Regards,
> Eugene
> 
> ________________________________
> 
> From: dsdp-tcf-dev-bounces@xxxxxxxxxxx
> [mailto:dsdp-tcf-dev-bounces@xxxxxxxxxxx] On Behalf Of
> ken.ryall@xxxxxxxxx
> Sent: Thursday, April 30, 2009 3:19 PM
> To: dsdp-tcf-dev@xxxxxxxxxxx
> Subject: [dsdp-tcf-dev] Handling errors when opening a channel
> 
> 
> I'd appreciate some advice on how to handle errors when opening a
> channel. I'm calling IPeer.openChannel but in this case the peer has
> shutdown and is no longer available.
> 
> java.net.ConnectException: Connection refused: connect
>     at java.net.PlainSocketImpl.socketConnect(Native Method)
>     at java.net.PlainSocketImpl.doConnect(Unknown Source)
>     at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
>     at java.net.PlainSocketImpl.connect(Unknown Source)
>     at java.net.SocksSocketImpl.connect(Unknown Source)
>     at java.net.Socket.connect(Unknown Source)
>     at java.net.Socket.connect(Unknown Source)
>     at java.net.Socket.<init>(Unknown Source)
>     at java.net.Socket.<init>(Unknown Source)
>     at org.eclipse.tm.tcf.core.ChannelTCP$1.run(ChannelTCP.java:70)
> 
> I've installed a ChannelOpenListener but that only tells you when it has
> been opened, not when something goes wrong. I'm looking for the best
> place to detect this. It looks like the channel gets terminated but I'm
> not sure how to listen for that.
> 
> Thanks - Ken 
> _______________________________________________
> dsdp-tcf-dev mailing list
> dsdp-tcf-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/dsdp-tcf-dev



Back to the top