gpt4 book ai didi

java - Telegram Java API-套接字连接问题

转载 作者:太空宇宙 更新时间:2023-11-04 06:35:01 26 4
gpt4 key购买 nike

我正在尝试使用 Telegram Java API Error message 'java.net.SocketException: socket failed: EACCES (Permission denied)'我从一些简单的 RPC 调用开始:

SampleApiState apiState = new SampleApiState(connections);
TLRequestAuthCheckPhone checkRequest = new TLRequestAuthCheckPhone("+1234567890");
TelegramApi api = new TelegramApi(apiState, new ApplicationInfo(),
new ApiCallback() {
@Override
public void onUpdatesInvalidated(TelegramApi api) {
// TODO Auto-generated method stub
Log.i(TAG, "onUpdatesInvalidated");
}

@Override
public void onAuthCancelled(TelegramApi api) {
// TODO Auto-generated method stub
Log.i(TAG, "onAuthCancelled");
}

@Override
public void onUpdate(TLAbsUpdates updates) {
// TODO Auto-generated method stub
Log.i(TAG, "onUpdate");
}
});
TLCheckedPhone checkedPhone = api.doRpcCall(checkRequest);

这是日志:

11524-11580/com.example.tltest W/System.err﹕ java.net.SocketException: socket failed: EACCES (Permission denied)
11524-11580/com.example.tltest W/System.err﹕ at libcore.io.IoBridge.socket(IoBridge.java:576)
11524-11580/com.example.tltest W/System.err﹕ at java.net.PlainSocketImpl.create(PlainSocketImpl.java:201)
11524-11580/com.example.tltest W/System.err﹕ at java.net.Socket.checkOpenAndCreate(Socket.java:664)
11524-11580/com.example.tltest W/System.err﹕ at java.net.Socket.connect(Socket.java:808)
11524-11580/com.example.tltest W/System.err﹕ at org.telegram.mtproto.transport.PlainTcpConnection.<init>(PlainTcpConnection.java:32)
11524-11580/com.example.tltest W/System.err﹕ at org.telegram.mtproto.pq.Authorizer.doAuth(Authorizer.java:198)
11524-11580/com.example.tltest W/System.err﹕ at org.telegram.api.engine.TelegramApi$ConnectionThread.waitForDc(TelegramApi.java:842)
11524-11580/com.example.tltest W/System.err﹕ at org.telegram.api.engine.TelegramApi$ConnectionThread.run(TelegramApi.java:907)
11524-11588/com.example.tltest I/System.out﹕ api#1001#Uploader:UploadFileThread iteration
11524-11580/com.example.tltest W/System.err﹕ Caused by: libcore.io.ErrnoException: socket failed: EACCES (Permission denied)
11524-11580/com.example.tltest W/System.err﹕ at libcore.io.Posix.socket(Native Method)
11524-11580/com.example.tltest W/System.err﹕ at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:181)
11524-11580/com.example.tltest W/System.err﹕ at libcore.io.IoBridge.socket(IoBridge.java:561)
11524-11580/com.example.tltest W/System.err﹕ ... 7 more
11524-11580/com.example.tltest I/System.out﹕ TransportRate:onConnectionFailure #1
11524-11580/com.example.tltest I/System.out﹕ TransportRate:Transport: #1 173.240.5.1:443 #1.0
11524-11580/com.example.tltest I/System.out﹕ TransportRate:tryConnection #1

连接失败后,它一次又一次尝试连接,但不是很成功。我无法找出原因是什么以及如何解决这个问题。也许有人有同样的问题?将非常感谢您的帮助)

最佳答案

从您发布的异常来看,它似乎是一个 Android 应用程序,这是一个权限问题。

java.net.SocketException: socket failed: EACCES (Permission denied)

尝试将其添加到 list 文件中:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

关于java - Telegram Java API-套接字连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25528007/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com