Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DSDP - Target Management » RSE:How to set timeout to stop the connecting state?
RSE:How to set timeout to stop the connecting state? [message #36082] Tue, 23 June 2009 06:20 Go to next message
hemeihua is currently offline hemeihuaFriend
Messages: 20
Registered: July 2009
Junior Member
I creat a FTP connection with the specified port such as 8092 which has
been used by other applications,and connect the FTP connection,but can not
open a Socket connected to a remote host at the specified port(8092) by
indirectly call {@link org.apache.commons.net.SocketClient$connect(String
hostname, int port)},and keep on connecting state for ever.

Here is my configuration:
- Windows XP PC running Eclipse 3.3.0 with plugin RSE (RSE-SDK-3.0.1.zip)

Here are my code:
/*creat a FTP connection with the specified port such as 8092*/
public IHost creatFTPConnection(String siteName, String ip, int port ){
IHost ftpSite = null;
IRSESystemType systemType =
RSECorePlugin.getTheCoreRegistry().getSystemTypeById(RSE_SYS TEM_TYPE_ID);
ISubSystemConfigurator[] configurators = getSubSystemConfigurators();
String[] defaultProfileNames =
sr.getSystemProfileManager().getActiveSystemProfileNames();
String aliasName = decorateAliasName(siteName);

if(defaultProfileNames.length > 0){
try {
ftpSite = sr.createHost(defaultProfileNames[0], systemType, aliasName,
ip,
"", "", 0,configurators);
} catch (Exception e) {
e.printStackTrace();
}
if(ftpSite != null){
ISubSystem[] subsystems = ftpSite.getSubSystems();
for (int i = 0; i < subsystems.length; i++){
ISubSystem subsystem = subsystems[i];
subsystem.getConnectorService().setPort(port);//port=8092
}
}
}
return ftpSite;
}

/*to connect the FTP connection with the specified port such as 8092*/
public class ConnectAllJob extends Job
{
private IHost fFtpSite, fTabDate;
private Viewer fViewer;
public ConnectAllJob(IHost site,IHost data, Viewer v )
{
super(SystemResources.ACTION_CONNECT_ALL_LABEL);
fFtpSite = site;
fTabDate = data;
fViewer = v;
}

public IStatus run(IProgressMonitor monitor)
{
List failedSystems = new ArrayList();
try
{
//forced instantiation of all subsystems
ISubSystem[] subsystems = fTabDate.getSubSystems();
for (int i = 0; i < subsystems.length; i++)
{
ISubSystem subsystem = subsystems[i];
IConnectorService system = subsystem.getConnectorService();
if (!subsystem.isConnected()
&&
subsystem.getSubSystemConfiguration().supportsSubSystemConne ct()
&& !failedSystems.contains(system))
{
try
{
subsystem.connect(monitor, false);
}
catch (SystemMessageException e) {
//TODO should we collect all messages and just show one dialog with
a MultiStatus?
failedSystems.add(system);
SystemMessageDialog.displayMessage(e);
}
catch (Exception e) {
failedSystems.add(system);
if ((e instanceof InterruptedException) || (e
instanceof OperationCanceledException)) {
// if the user was prompted for password and cancelled
// or if the connect was interrupted for some other
reason
// we don't attempt to connect the other subsystems
break;
}
SystemBasePlugin.logError(
e.getLocalizedMessage()!=null ? e.getLocalizedMessage() :
e.getClass().getName(),
e);

SystemMessageDialog.displayErrorMessage(getShell(), e.getMessage());
}
}
}
}
catch (Exception exc)
{
} // msg already shown
if (failedSystems.size() > 0)
{
return Status.CANCEL_STATUS;
}
}
}
How to set timeout to stop the connecting state or what is the best way to
handle this problem?
Somebody can help me?
Best Regards,
hemeihua
Re: RSE:How to set timeout to stop the connecting state? [message #36794 is a reply to message #36082] Thu, 02 July 2009 04:34 Go to previous messageGo to next message
hemeihua is currently offline hemeihuaFriend
Messages: 20
Registered: July 2009
Junior Member
Who will help me ?
Re: RSE:How to set timeout to stop the connecting state? [message #36863 is a reply to message #36794] Thu, 02 July 2009 15:04 Go to previous messageGo to next message
David McKnight is currently offline David McKnightFriend
Messages: 244
Registered: July 2009
Senior Member
Hi hemeihua,

I don't know that much about the details of the FTP service implementation
but I'll try to help here. FTPService leverages FTPClient from apache
commons. There is a method to get the FTPClient, getFTPClient() from the
service. FTPClient extends SocketClient which has the following method:

/**
* Sets the connection timeout in milliseconds, which will be passed to the
{@link Socket} object's
* connect() method.
* @param connectTimeout The connection timeout to use (in ms)
* @since 2.0
*/
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
Is that what you're looking for?

Dave



"hemeihua " <he.meihua@zte.com.cn> wrote in message
news:e9278e88eaa09aff19633437772e2976$1@www.eclipse.org...
> Who will help me ?
>
Re: RSE:How to set timeout to stop the connecting state? [message #37099 is a reply to message #36863] Tue, 07 July 2009 01:06 Go to previous messageGo to next message
hemeihua is currently offline hemeihuaFriend
Messages: 20
Registered: July 2009
Junior Member
Hi David,
My configuration:
- Windows XP PC running Eclipse 3.3.0 with plugin RSE (RSE-SDK-3.0.1.zip)

The class of org.apache.commons.net.SocketClient has not the method:

/**
* Sets the connection timeout in milliseconds, which will be passed to the
{@link Socket} object's
* connect() method.
* @param connectTimeout The connection timeout to use (in ms)
* @since 2.0
*/
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}

but has the two methods:
/**
* Set the timeout in milliseconds of a currently open connection.
* Only call this method after a connection has been opened
* by {@link #connect connect()}.
* <p>
* @param timeout The timeout in milliseconds to use for the currently
* open socket connection.
* @exception SocketException If the operation fails.
*/
public void setSoTimeout(int timeout) throws SocketException
{
_socket_.setSoTimeout(timeout);
}


/**
* Set the default timeout in milliseconds to use when opening a socket.
* This value is only used previous to a call to
* {@link #connect connect()}
* and should not be confused with {@link #setSoTimeout setSoTimeout()}
* which operates on an the currently opened socket. _timeout_ contains
* the new timeout value.
* <p>
* @param timeout The timeout in milliseconds to use for the socket
* connection.
*/
public void setDefaultTimeout(int timeout)
{
_timeout_ = timeout;
}

I use one of the two methods to set connect timeout(60000ms) ,
but it will cause another problem of "java.net.SocketTimeoutException:
Read timed out"when a connection connected ftp server and wait a bit about
60000ms and transmit a file ,
then the SocketTimeoutException error occurred.

Have you another method to set connection timeout? How to deal with this
problem?
Thanks ahead of time,
hemeihua
Re: RSE:How to set timeout to stop the connecting state? [message #37235 is a reply to message #37099] Wed, 08 July 2009 17:31 Go to previous message
David McKnight is currently offline David McKnightFriend
Messages: 244
Registered: July 2009
Senior Member
Are you able to use the RSE 3.1 driver instead of RSE 3.0.1? The latest
version uses an updated SocketClient which has the setConnectTimeout()
method.


"hemeihua " <he.meihua@zte.com.cn> wrote in message
news:2f379b2cc0f803a2240136840a467da5$1@www.eclipse.org...
> Hi David,
> My configuration:
> - Windows XP PC running Eclipse 3.3.0 with plugin RSE (RSE-SDK-3.0.1.zip)
>
> The class of org.apache.commons.net.SocketClient has not the method:
>
> /**
> * Sets the connection timeout in milliseconds, which will be passed to the
> {@link Socket} object's
> * connect() method.
> * @param connectTimeout The connection timeout to use (in ms)
> * @since 2.0
> */
> public void setConnectTimeout(int connectTimeout) {
> this.connectTimeout = connectTimeout;
> }
>
> but has the two methods:
> /**
> * Set the timeout in milliseconds of a currently open connection.
> * Only call this method after a connection has been opened
> * by {@link #connect connect()}.
> * <p>
> * @param timeout The timeout in milliseconds to use for the currently
> * open socket connection.
> * @exception SocketException If the operation fails.
> */
> public void setSoTimeout(int timeout) throws SocketException
> {
> _socket_.setSoTimeout(timeout);
> }
>
>
> /**
> * Set the default timeout in milliseconds to use when opening a socket.
> * This value is only used previous to a call to
> * {@link #connect connect()}
> * and should not be confused with {@link #setSoTimeout setSoTimeout()}
> * which operates on an the currently opened socket. _timeout_ contains
> * the new timeout value.
> * <p>
> * @param timeout The timeout in milliseconds to use for the socket
> * connection.
> */
> public void setDefaultTimeout(int timeout)
> {
> _timeout_ = timeout;
> }
>
> I use one of the two methods to set connect timeout(60000ms) , but it will
> cause another problem of "java.net.SocketTimeoutException: Read timed
> out"when a connection connected ftp server and wait a bit about 60000ms
> and transmit a file , then the SocketTimeoutException error occurred.
>
> Have you another method to set connection timeout? How to deal with this
> problem?
> Thanks ahead of time,
> hemeihua
>
Re: RSE:How to set timeout to stop the connecting state? [message #581587 is a reply to message #36082] Thu, 02 July 2009 04:34 Go to previous message
hemeihua is currently offline hemeihuaFriend
Messages: 20
Registered: July 2009
Junior Member
Who will help me ?
Re: RSE:How to set timeout to stop the connecting state? [message #581630 is a reply to message #36794] Thu, 02 July 2009 15:04 Go to previous message
David McKnight is currently offline David McKnightFriend
Messages: 244
Registered: July 2009
Senior Member
Hi hemeihua,

I don't know that much about the details of the FTP service implementation
but I'll try to help here. FTPService leverages FTPClient from apache
commons. There is a method to get the FTPClient, getFTPClient() from the
service. FTPClient extends SocketClient which has the following method:

/**
* Sets the connection timeout in milliseconds, which will be passed to the
{@link Socket} object's
* connect() method.
* @param connectTimeout The connection timeout to use (in ms)
* @since 2.0
*/
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
Is that what you're looking for?

Dave



"hemeihua " <he.meihua@zte.com.cn> wrote in message
news:e9278e88eaa09aff19633437772e2976$1@www.eclipse.org...
> Who will help me ?
>
Re: RSE:How to set timeout to stop the connecting state? [message #581800 is a reply to message #36863] Tue, 07 July 2009 01:06 Go to previous message
hemeihua is currently offline hemeihuaFriend
Messages: 20
Registered: July 2009
Junior Member
Hi David,
My configuration:
- Windows XP PC running Eclipse 3.3.0 with plugin RSE (RSE-SDK-3.0.1.zip)

The class of org.apache.commons.net.SocketClient has not the method:

/**
* Sets the connection timeout in milliseconds, which will be passed to the
{@link Socket} object's
* connect() method.
* @param connectTimeout The connection timeout to use (in ms)
* @since 2.0
*/
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}

but has the two methods:
/**
* Set the timeout in milliseconds of a currently open connection.
* Only call this method after a connection has been opened
* by {@link #connect connect()}.
* <p>
* @param timeout The timeout in milliseconds to use for the currently
* open socket connection.
* @exception SocketException If the operation fails.
*/
public void setSoTimeout(int timeout) throws SocketException
{
_socket_.setSoTimeout(timeout);
}


/**
* Set the default timeout in milliseconds to use when opening a socket.
* This value is only used previous to a call to
* {@link #connect connect()}
* and should not be confused with {@link #setSoTimeout setSoTimeout()}
* which operates on an the currently opened socket. _timeout_ contains
* the new timeout value.
* <p>
* @param timeout The timeout in milliseconds to use for the socket
* connection.
*/
public void setDefaultTimeout(int timeout)
{
_timeout_ = timeout;
}

I use one of the two methods to set connect timeout(60000ms) ,
but it will cause another problem of "java.net.SocketTimeoutException:
Read timed out"when a connection connected ftp server and wait a bit about
60000ms and transmit a file ,
then the SocketTimeoutException error occurred.

Have you another method to set connection timeout? How to deal with this
problem?
Thanks ahead of time,
hemeihua
Re: RSE:How to set timeout to stop the connecting state? [message #581876 is a reply to message #37099] Wed, 08 July 2009 17:31 Go to previous message
David McKnight is currently offline David McKnightFriend
Messages: 244
Registered: July 2009
Senior Member
Are you able to use the RSE 3.1 driver instead of RSE 3.0.1? The latest
version uses an updated SocketClient which has the setConnectTimeout()
method.


"hemeihua " <he.meihua@zte.com.cn> wrote in message
news:2f379b2cc0f803a2240136840a467da5$1@www.eclipse.org...
> Hi David,
> My configuration:
> - Windows XP PC running Eclipse 3.3.0 with plugin RSE (RSE-SDK-3.0.1.zip)
>
> The class of org.apache.commons.net.SocketClient has not the method:
>
> /**
> * Sets the connection timeout in milliseconds, which will be passed to the
> {@link Socket} object's
> * connect() method.
> * @param connectTimeout The connection timeout to use (in ms)
> * @since 2.0
> */
> public void setConnectTimeout(int connectTimeout) {
> this.connectTimeout = connectTimeout;
> }
>
> but has the two methods:
> /**
> * Set the timeout in milliseconds of a currently open connection.
> * Only call this method after a connection has been opened
> * by {@link #connect connect()}.
> * <p>
> * @param timeout The timeout in milliseconds to use for the currently
> * open socket connection.
> * @exception SocketException If the operation fails.
> */
> public void setSoTimeout(int timeout) throws SocketException
> {
> _socket_.setSoTimeout(timeout);
> }
>
>
> /**
> * Set the default timeout in milliseconds to use when opening a socket.
> * This value is only used previous to a call to
> * {@link #connect connect()}
> * and should not be confused with {@link #setSoTimeout setSoTimeout()}
> * which operates on an the currently opened socket. _timeout_ contains
> * the new timeout value.
> * <p>
> * @param timeout The timeout in milliseconds to use for the socket
> * connection.
> */
> public void setDefaultTimeout(int timeout)
> {
> _timeout_ = timeout;
> }
>
> I use one of the two methods to set connect timeout(60000ms) , but it will
> cause another problem of "java.net.SocketTimeoutException: Read timed
> out"when a connection connected ftp server and wait a bit about 60000ms
> and transmit a file , then the SocketTimeoutException error occurred.
>
> Have you another method to set connection timeout? How to deal with this
> problem?
> Thanks ahead of time,
> hemeihua
>
Previous Topic:RSE can't open files in some directory, which give the RSEG1067 error
Next Topic:RSE:What is the use of RemoteSystemsTempFiles in workspace?
Goto Forum:
  


Current Time: Fri Apr 19 13:49:35 GMT 2024

Powered by FUDForum. Page generated in 0.02294 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top