我试图通过android代码连接到hdfs集群。但我正面临socketError中的问题。下面我包含了日志文件和代码。正在建立连接但是在创建连接套接字时出现问题。
Connect_Ssh:
DllDate: Aug 30 2017
ChilkatVersion: 9.5.0.69
UnlockPrefix: Anything for 30-day trial
Architecture: Little Endian; 32-bit
Language: Android Java
VerboseLogging: 0
connectInner:
hostname: 202.53.13.23
port: 1032
sshConnect:
connectSocket:
connect_ipv6_or_ipv4:
ai_family: 2
ai_socktype: 1
ai_protocol: 6
socketErrno: 13
socketError: Permission denied
Failed to create socket for connecting.
--connect_ipv6_or_ipv4
--connectSocket
Failed to establish initial TCP/IP connection
hostname: 202.53.13.23
port: 1032
--sshConnect
--connectInner
Failed.
--Connect_Ssh
--ChilkatLog
以下是要打印上述日志文件的代码。 代码:
package com.example.sunny.clusteraccess;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.chilkatsoft.CkSsh;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "Chilkat";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CkSsh ssh = new CkSsh();
// Any string automatically begins a fully-functional 30-day trial.
boolean success = ssh.UnlockComponent("Anything for 30-day trial");
if (success != true) {
Log.i(TAG, ssh.lastErrorText());
return;
}
String hostname;
int port;
// Hostname may be an IP address or hostname:
hostname = "202.53.13.23";
port = 22;
success = ssh.Connect(hostname,port);
if (success != true) {
Log.i(TAG, ssh.lastErrorText());
return;
}
success = ssh.AuthenticatePw("student","kmit");
if (success != true) {
Log.i(TAG, ssh.lastErrorText());
return;
}
Log.e(""+success,"");
int channelNum;
channelNum = ssh.OpenSessionChannel();
if (channelNum < 0) {
Log.i(TAG, ssh.lastErrorText());
return;
}
success = ssh.SendReqExec(channelNum,"hdfs dfs -ls");
if (success != true) {
Log.i(TAG, ssh.lastErrorText());
return;
}
success = ssh.ChannelReceiveToClose(channelNum);
if (success != true) {
Log.i(TAG, ssh.lastErrorText());
return;
}
String cmdOutput = ssh.getReceivedText(channelNum,"ansi");
if (ssh.get_LastMethodSuccess() != true) {
Log.i(TAG, ssh.lastErrorText());
return;
}
Log.e(TAG, cmdOutput);
ssh.Disconnect();
}
static {
System.loadLibrary("chilkat");
}
}
答案 0 :(得分:1)
您是否在代码中提供了Internet权限?尝试在清单中添加此内容 文件,如果你还没有。
<uses-permission android:name="android.permission.INTERNET" />