, когда я пытаюсь подключиться через ssh от моего приложения для Android к raspeberry, используя имя хоста "raspberrypi.local" и порт "2222", показывающий сообщение об ошибке, в котором отказано соединение, но когда я выполняю тот же код, используя статический локальный ip, он работает.Как это исправить?пожалуйста, помогите мне.
try {
SSHClient ssh;
Session session = null;
AndroidConfig config = new AndroidConfig();
config.setKeepAliveProvider(KeepAliveProvider.KEEP_ALIVE);
ssh = new SSHClient(config);
ssh.addHostKeyVerifier(new PromiscuousVerifier());
//if (!ssh.isConnected())
ssh.connect("raspberrypi.local", 2222);
ssh.getConnection().getKeepAlive().setKeepAliveInterval(5);
ssh.authPassword("pi", new PasswordFinder() {
@Override
public char[] reqPassword(Resource<?> resource) {
return "here i used my password".toCharArray();
}
@Override
public boolean shouldRetry(Resource<?> resource) {
return false;
}
});
//ssh.authPublickey(System.getProperty("user.name"));
session = ssh.startSession();
Log.e(TAG, "subscribe: is connected " + ssh.isConnected());
Session.Command cmd = session.exec(command);
emitter.onSuccess(cmd);
} catch (Exception e) {
e.printStackTrace();
emitter.onError(e);
}