Thanks Atsuhiko

There was never tested, I added in my code but now I do not know what
is the best
value to place, as you can see the code attached, I put 60 in value. is this
good?



------~-------~--~----~--~--~---------~--~----~------------~-------~--~----~
* Life would be much easier if I had the source code!*
--~--~---------~--~----~------------~-------~--~----~--~--~---------~--~----~------------~-------~--~----~
Please delete my email address when forwarding.
Apague meu endereço ao repassar as mensagens.



2011/9/13 Atsuhiko Yamanaka <[email protected]>

> Hi,
>
>   +-From: Xamag Productions <[email protected]> --
>   |_Date: Mon, 12 Sep 2011 15:27:45 +0200 _________
>    |
>   |I have an application that uses jsch, and stays on 24/24, and take place
>   |during some periods that gives com.jcraft.jsch.JSchException exception:
>   |java.io.IOException: Pipe closed
>   |Someone help me to prevent this problem? or the possible cause
>
> Have you tried Session#setServerAliveInterval(int msec) ?
>
>
> Sincerely,
> --
> Atsuhiko Yamanaka
> JCraft,Inc.
> 1-14-20 HONCHO AOBA-KU,
> SENDAI, MIYAGI 980-0014 Japan.
> Tel +81-22-723-2150
>    +1-415-578-3454
> Skype callto://jcraft/
> Twitter: http://twitter.com/ymnk
> Facebook: http://facebook.com/aymnk
>
/*
 * Copyright (c) 2003-2011 ????. All rights reserved.
 */


public class SSHConnectionImpl
	implements SSHConnection
{
	// ~ Instance fields
	// ----------------------------------------------------------------------------

	private Session _session; // sessão estabelecida com servidor SSH

	private ChannelSftp _channel; // canal para transferência de ficheiros
									// de/para máquina remota

	private String _extension = "";// a extensão dos ficheiros a serem listados
									// no metodo List

	private String _getDir; // o diretório remoto de qual "puxaremos" ficheiros

	private String _putDir; // o diretório remoto para onde "colocaremos"
							// ficheiros

	private String _gotFileName; // nome do ficheiro gettado para ser lembrado e
									// posteriormente deletado

	private String _putFileName; // nome do ficheiro que foi put para ser
									// lembrado e posteriormente usado para o


	// ~ Constructor
	// -------------------------------------------------------------------------------

	protected SSHConnectionImpl(String host,
			String user,
			String password,
			int port,
			String knownHostsPath,
			String getDir,
			String putDir,
			String extension) throws SSHException
	{
		_getDir = getDir;
		_putDir = putDir;
		_extension = extension;

		JSch jsch = new JSch();
		try
		{
			File knownHostsFile = new File(knownHostsPath);
			if (!knownHostsFile.exists())
			{
				logger.error("Não existe o caminho para o ficheiro: "
						+ knownHostsPath);
				throw new SSHException("Não existe o caminho para o ficheiro: "
						+ knownHostsPath);
			}
			jsch.setKnownHosts(knownHostsPath);
			_session = jsch.getSession(user, host, port);
			_session.setPassword(password);

			java.util.Properties config = new java.util.Properties();
			config.put("StrictHostKeyChecking", "yes");
			_session.setConfig(config);
			// indicado por Atsuhiko Yamanaka
			_session.setServerAliveInterval(60);
			_session.connect();

			_channel = (ChannelSftp) _session.openChannel("sftp");
			_channel.connect();
			parametros = new ParamSSH(host,
					user,
					password,
					port,
					knownHostsPath,
					getDir,
					putDir,
					extension);
		}
		catch (JSchException jschX)
		{

			logger
				.error("foi encontrada uma excepção jsch durante a abertura da conexão: "
						+ jschX);
			logger.error("Problemas ao abrir uma conexão JSch ", jschX);
		}
	}

	// ~ Methods

}
------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users

Reply via email to