You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to create app using your api. Create ApiStorage extended AbsApiState. But when I try to connect I get this TelegramApi#1001:Phase 0 in 1 ms TelegramApi#1001:Phase 1 in 90 ms TelegramApi#1001:Timeout Iteration TelegramApi#1001:Connection iteration TelegramApi#1001:#1: waitForDc TelegramApi#1001:#1: Creating proto for dc TelegramApi#1001:#1: Creating key TelegramApi#1001:Phase 2 in 4 ms TelegramApi#1001:Sender iteration api#1001#Downloader:DownloadFileThread iteration api#1001#Downloader:DownloadFileThread iteration api#1001#Uploader:UploadFileThread iteration api#1001#Uploader:UploadFileThread iteration api#1001#Uploader:UploadFileThread iteration api#1001#Downloader:DownloadFileThread iteration api#1001#Downloader:DownloadFileThread iteration TransportRate:Transport: #1 149.154.167.91:443 #1.0 api#1001#Uploader:UploadFileThread iteration TelegramApi#1001:Phase 3 in 8 ms TransportRate:tryConnection #1 java.net.BindException: Cannot assign requested address: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.telegram.mtproto.transport.PlainTcpConnection.<init>(PlainTcpConnection.java:32)
Here is the code of AbsApiState
`public class ApiStorage implements AbsApiState, Serializable {
private HashMap<Integer, ConnectionInfo[]> connections = new HashMap<Integer, ConnectionInfo[]>();
private HashMap<Integer, byte[]> keys = new HashMap<Integer, byte[]>();
private HashMap<Integer, Boolean> isAuth = new HashMap<Integer, Boolean>();
private int primaryDc = 1;
private static final String DC1 = "149.154.167.40";
private static final String DC2 = "149.154.167.50";
public ApiStorage() {
connections.put(1, new ConnectionInfo[]{
new ConnectionInfo(1, 0, DC2, 443)
});
}
@Override
public int getPrimaryDc() {
return primaryDc;
}
@Override
public void setPrimaryDc(int i) {
primaryDc = i;
}
@Override
public boolean isAuthenticated(int dcId) {
if (isAuth.containsKey(dcId)) {
return isAuth.get(dcId);
}
return false;
}
@Override
public void setAuthenticated(int dcId, boolean auth) {
isAuth.put(dcId, auth);
}
@Override
public void updateSettings(TLConfig config) {
connections.clear();
HashMap<Integer, ArrayList<ConnectionInfo>> tConnections = new HashMap<Integer, ArrayList<ConnectionInfo>>();
int id = 0;
for (TLDcOption option : config.getDcOptions()) {
if (!tConnections.containsKey(option.getId())) {
tConnections.put(option.getId(), new ArrayList<ConnectionInfo>());
}
tConnections.get(option.getId()).add(new ConnectionInfo(id++, 0, option.getIpAddress(), option.getPort()));
}
for (Integer dc : tConnections.keySet()) {
connections.put(dc, tConnections.get(dc).toArray(new ConnectionInfo[0]));
}
}
@Override
public byte[] getAuthKey(int dcId) {
return keys.get(dcId);
}
@Override
public void putAuthKey(int dcId, byte[] key) {
keys.put(dcId, key);
}
@Override
public ConnectionInfo[] getAvailableConnections(int dcId) {
if (!connections.containsKey(dcId)) {
return new ConnectionInfo[0];
}
return connections.get(dcId);
}
@Override
public AbsMTProtoState getMtProtoState(int dcId) {
return new AbsMTProtoState() {
private KnownSalt[] knownSalts = new KnownSalt[0];
@Override
public byte[] getAuthKey() {
return ApiStorage.this.getAuthKey(dcId);
}
@Override
public ConnectionInfo[] getAvailableConnections() {
return ApiStorage.this.getAvailableConnections(dcId);
}
@Override
public KnownSalt[] readKnownSalts() {
return knownSalts;
}
@Override
protected void writeKnownSalts(KnownSalt[] salts) {
knownSalts = salts;
}
};
}
@Override
public void resetAuth() {
isAuth.clear();
}
@Override
public void reset() {
isAuth.clear();
keys.clear();
}
public void saveState(String fileName, ApiStorage mas) {
try {
FileOutputStream fileOut = new FileOutputStream(fileName + ".sta");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(mas);
out.close();
fileOut.close();
} catch (IOException i) {
i.printStackTrace();
}
}
public ApiStorage loadState(String fileName) {
try {
FileInputStream fileIn = new FileInputStream(fileName + ".sta");
ObjectInputStream in = new ObjectInputStream(fileIn);
ApiStorage mas = (ApiStorage) in.readObject();
in.close();
fileIn.close();
return mas;
} catch (IOException i) {
return null;
} catch (ClassNotFoundException c) {
c.printStackTrace();
}
return null;
}
}`
What am I doing wrong?
The text was updated successfully, but these errors were encountered:
I try to create app using your api. Create ApiStorage extended AbsApiState. But when I try to connect I get this
TelegramApi#1001:Phase 0 in 1 ms TelegramApi#1001:Phase 1 in 90 ms TelegramApi#1001:Timeout Iteration TelegramApi#1001:Connection iteration TelegramApi#1001:#1: waitForDc TelegramApi#1001:#1: Creating proto for dc TelegramApi#1001:#1: Creating key TelegramApi#1001:Phase 2 in 4 ms TelegramApi#1001:Sender iteration api#1001#Downloader:DownloadFileThread iteration api#1001#Downloader:DownloadFileThread iteration api#1001#Uploader:UploadFileThread iteration api#1001#Uploader:UploadFileThread iteration api#1001#Uploader:UploadFileThread iteration api#1001#Downloader:DownloadFileThread iteration api#1001#Downloader:DownloadFileThread iteration TransportRate:Transport: #1 149.154.167.91:443 #1.0 api#1001#Uploader:UploadFileThread iteration TelegramApi#1001:Phase 3 in 8 ms TransportRate:tryConnection #1 java.net.BindException: Cannot assign requested address: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.telegram.mtproto.transport.PlainTcpConnection.<init>(PlainTcpConnection.java:32)
Here is the code of AbsApiState
`public class ApiStorage implements AbsApiState, Serializable {
}`
What am I doing wrong?
The text was updated successfully, but these errors were encountered: