1

I'm trying to use Telegram Java API https://github.com/ardock/telegram-api and I started with some simple RPC call:

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);

And here is log:

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

After connection failure, it tries to connect again and again, but not very successfully. I couldn't find out what's the reason and how to solve this problem. Maybe someone had same problem? Will be very gratefull for some help)

greenfrvr
  • 643
  • 6
  • 19
  • The only other examples of an exception like this are appearing in Android-based apps, and this does *seem* like an Android app, but I'm not 100% sure. Is it an Android app, or some other standalone desktop app? – Makoto Aug 27 '14 at 13:09
  • yes, I'm trying to work with this API in Android app – greenfrvr Aug 27 '14 at 13:14

1 Answers1

1

From the exception you posted it seems it is an android app and this is a permission problem.

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

Try to add this to the manifest file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
bpgergo
  • 15,669
  • 5
  • 44
  • 68