我正在尝试通过我的android应用程序使用smack库连接到openfire服务器。当我连接到服务器时,它给我和错误
以下地址失败:“192.168.0.31:5222”失败,因为java.net.SocketException:套接字失败:EACCES(拒绝权限)
public void init(String mUsername, String mPassword) {
Log.i(TAG, "connect()");
config = XMPPTCPConnectionConfiguration.builder();
config.setServiceName(mServiceName);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setHost(mServiceName);
config.setPort(5222);
config.setDebuggerEnabled(true);
config.setResource("sender");
// config.setCompressionEnabled(true);
config.setUsernameAndPassword(mUsername, mPassword);
XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
XMPPTCPConnection.setUseStreamManagementDefault(true);
mConnection = new XMPPTCPConnection(config.build());
mConnection.addConnectionListener(this);
ChatManager.getInstanceFor(mConnection).addChatListener(this);
gson = new Gson();
connectAndLoginAnonymously();
}
public void connectAndLoginAnonymously() {
mRegisterTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
mConnection.connect();
DeliveryReceiptManager dm = DeliveryReceiptManager
.getInstanceFor(mConnection);
dm.setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.always);
dm.addReceiptReceivedListener(new ReceiptReceivedListener() {
@Override
public void onReceiptReceived(final String fromid,
final String toid, final String msgid,
final Stanza packet) {
}
});
mConnection.login();
} catch (SmackException | XMPPException | IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void res) {
}
};
// execute AsyncTask
mRegisterTask.execute();
}
public void disconnect() {
Log.i(TAG, "disconnect()");
if (mConnection != null) {
mConnection.disconnect();
}
}
//For Creating new User.
public boolean createNewAccount(String username, String newpassword) {
boolean status = false;
if (mConnection == null) {
try {
mConnection.connect();
} catch (SmackException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (XMPPException e) {
e.printStackTrace();
}
}
try {
// String newusername = username + mConnection.getServiceName();
Log.i("service", mConnection.getServiceName());
AccountManager accountManager = AccountManager.getInstance(mConnection);
accountManager.createAccount(username, newpassword);
status = true;
} catch (SmackException.NoResponseException e) {
status = false;
e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
status = false;
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
status = false;
}
mConnection.disconnect();
return status;
}
从我的登录活动调用SmackConnection.init(用户,密码);它给出java.net.SocketException权限被拒绝的错误。
错误日志如下所示。
04-05 18:28:18.142 9575-9575/dhaval.com.chatdemo I/SMACK: connect()
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err:
org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: '192.168.0.31:5222' failed because java.net.SocketException: socket failed: EACCES (Permission denied)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:605)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:839)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:365)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at dhaval.com.chatdemo.SmackConnection$1.doInBackground(SmackConnection.java:104)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at dhaval.com.chatdemo.SmackConnection$1.doInBackground(SmackConnection.java:100)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-05 18:28:18.152 9575-9604/dhaval.com.chatdemo W/System.err: at java.lang.Thread.run(Thread.java:841)
清单代码:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dhaval.com.chatdemo">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".CreateAccountPage"></activity>
</application>
希望您的清单中没有使用权限INTERNET。
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
我正在使用Spring 5网络流量、SpringBoot 2和Reactive MongoDB构建一个POC。在使用maven插件构建项目时,我得到了如下错误MongoDB连接错误:- 以下是我的申请表。属性文件:- 波姆。xml:- 请告知这里可能存在什么问题?我是否需要在我的机器上显式安装MongoDB并在运行此项目之前运行它。我相信MongoDB实例将自行运行,因为SpringBoot将在运
所以我可以在没有sudo的情况下运行docker命令,但是同样的错误也出现在和logout/login和reboot上。 是因为Docker还是Gradle?
问题内容: 我正在使用Nginx和Gunicorn配置Django项目。 在Nginx服务器中访问端口时,我的错误日志文件中出现以下错误; 2014/05/30 11:59:42 [crit] 4075#0:* 6 connect()到127.0.0.1:8001在连接到上游时失败(13:权限被拒绝),客户端:127.0.0.1,服务器:localhost,请求:“ GET / HTTP / 1.
我已经找到了所有的解决方案并应用到我的项目中。但它们不起作用。我被拒绝了这个许可。我已经把所有可能的许可都放进了清单文件。请告诉我我的项目出了什么问题。 我的manifest.xml Logcat:
我刚刚运行Dockerfile在jenkins安装然后我得到以下错误: 尝试连接到处的Docker守护程序套接字时,权限被拒绝unix:///var/run/docker.sock:邮递http:///var/run/docker.sock/v1.40/build?buildargs={}
问题内容: 我最近了解了客户端和服务器之间的套接字编程。因此,我想到了进行客户端和服务器连接的练习。但是,当我尝试运行代码时遇到了以下错误消息: 线程“ main” java.net.ConnectException中的异常:连接被拒绝:connect 这是我的客户类代码: 这是我的服务器代码: 完整的错误消息是: 希望有人能帮助我,谢谢。 问题答案: 您的程序中有2个问题: 您使用的端口是 众所