Problem getting API_ID
Hi, I get a "boolTrue#997275b5" response calling register.saveDeveloperInfo#d2dab7e9 but not sms received.
The server that I used is: 173.240.5.253:443
Thanks!
This is the trace of the last try:
03-03 17:41:21.550: I/System.out(6454): Authorizer:Solved PQ in 617 ms 03-03 17:41:22.431: I/System.out(6454): TransportRate:Transport: #0 173.240.5.253:443 #1.0 03-03 17:41:22.441: I/System.out(6454):
MTProto#1001:sendMessage #2 register.saveDeveloperInfo#d2dab7e9
03-03 17:41:22.441: I/System.out(6454): TransportRate:tryConnection #0 03-03 17:41:22.441: I/System.out(6454): ie 03-03 17:41:22.621: I/System.out(6454): TransportRate:tryConnection #0 03-03 17:41:22.641: I/System.out(6454): Scheduller:Using high priority scheduling 03-03 17:41:22.641: I/System.out(6454): MTProto#1001#Scheduller:Iteration: count: 1, confirm:0 03-03 17:41:22.641: I/System.out(6454): MTProto#1001#Scheduller:Building package 03-03 17:41:22.651: I/System.out(6454): MTProto#1001#Scheduller:Adding msg_ack: 0 03-03 17:41:22.661: I/System.out(6454): MTProto#1001#Scheduller:Adding package: #2 register.saveDeveloperInfo#d2dab7e9 (5986604074642964484, 1) 03-03 17:41:22.661: I/System.out(6454): MTProto#1001#Scheduller:Sending Package (5986604074642964488, 2) 03-03 17:41:22.691: I/System.out(6454): Scheduller:Prepare package: ping#7abe77ec of size 12 03-03 17:41:22.691: I/System.out(6454): Scheduller:Total size: 12 03-03 17:41:22.691: I/System.out(6454): Scheduller:Prepare package: ping_delay_disconnect#f3427b8c of size 16 03-03 17:41:22.691: I/System.out(6454): Scheduller:Total size: 28 03-03 17:41:22.691: I/System.out(6454): MTProto#1001#Scheduller:Iteration: count: 2, confirm:0 03-03 17:41:22.691: I/System.out(6454): MTProto#1001#Scheduller:Building package 03-03 17:41:22.691: I/System.out(6454): MTProto#1001#Scheduller:Adding package: #3 ping#7abe77ec (5986604074642964492, 3) 03-03 17:41:22.691: I/System.out(6454): MTProto#1001#Scheduller:Adding package: #4 ping_delay_disconnect#f3427b8c (5986604074642964496, 5) 03-03 17:41:22.691: I/System.out(6454): MTProto#1001#Scheduller:Sending Package (5986604074642964500, 6) 03-03 17:41:22.911: I/System.out(6454): MTProto#1001#Transport2:Start reading message: -1319958582 03-03 17:41:22.921: I/System.out(6454): MTProto#1001#Transport2:Breaking context 03-03 17:41:22.921: I/System.out(6454): MTProto#1001:onChannelBroken (#2) 03-03 17:41:22.921: I/System.out(6454): MTProto#1001#Transport2:DieThread exit 03-03 17:41:22.921: I/System.out(6454): MTProto#1001#BackOff:onFailureNoWait 03-03 17:41:22.931: I/System.out(6454): TransportRate:onConnectionFailure #0 03-03 17:41:22.931: I/System.out(6454): TransportRate:Transport: #0 173.240.5.253:443 #1.0 03-03 17:41:22.931: I/System.out(6454): MTProto#1001#Scheduller:Forgetting message: #3 03-03 17:41:22.941: I/System.out(6454): MTProto#1001#Scheduller:Forgetting message: #4 03-03 17:41:22.951: I/System.out(6454): Scheduller:Prepare package: ping#7abe77ec of size 12 03-03 17:41:22.951: I/System.out(6454): Scheduller:Total size: 12 03-03 17:41:22.951: I/System.out(6454): MTProto#1001#Scheduller:Iteration: count: 1, confirm:0 03-03 17:41:22.961: I/System.out(6454): MTProto#1001#Scheduller:Building package 03-03 17:41:22.961: I/System.out(6454): TransportRate:tryConnection #0 03-03 17:41:22.971: I/System.out(6454): MTProto#1001#Scheduller:Single package: #5 ping#7abe77ec (5986604078937931776, 7) 03-03 17:41:23.222: I/System.out(6454): MTProto#1001#Transport3:Start reading message: 196 03-03 17:41:23.242: I/System.out(6454): MTProto#1001:Decrypted in 16 ms 03-03 17:41:23.242: I/System.out(6454): MTProto#1001#BackOff:onSuccess 03-03 17:41:23.242: I/System.out(6454): MTProto#1001#BackOff:reset 03-03 17:41:23.252: I/System.out(6454): TransportRate:onConnectionSuccess #0 03-03 17:41:23.252: I/System.out(6454): TransportRate:Transport: #0 173.240.5.253:443 #1.0 03-03 17:41:23.252: I/System.out(6454): MTProto#1001:MessageArrived (#3): time: 1393864881 03-03 17:41:23.262: I/System.out(6454): MTProto#1001:MessageArrived (#3): seqNo: 4, msgId:5986604081249051649 03-03 17:41:23.272: I/System.out(6454): Scheduller:Prepare package: ping#7abe77ec of size 12 03-03 17:41:23.272: I/System.out(6454): MTProto#1001:Salt check timeout 03-03 17:41:23.272: I/System.out(6454): Scheduller:Total size: 12 03-03 17:41:23.272: I/System.out(6454): MTProto#1001:Too fiew actual salts: 0, requesting news 03-03 17:41:23.272: I/System.out(6454): MTProto#1001#Scheduller:Iteration: count: 1, confirm:0 03-03 17:41:23.282: I/System.out(6454): MTProto#1001#Scheduller:Building package 03-03 17:41:23.282: I/System.out(6454): MTProto#1001:MTProtoMessage: new_session_created#9ec20908 03-03 17:41:23.282: I/System.out(6454): MTProto#1001#Scheduller:Adding msg_ack: 1 03-03 17:41:23.282: I/System.out(6454): MTProto#1001#Scheduller:Adding package: #6 ping#7abe77ec (5986604078937931784, 9) 03-03 17:41:23.282: E/telegram(6454): sesion createdmtproto#1001 03-03 17:41:23.282: I/System.out(6454): MTProto#1001#Scheduller:Sending Package (5986604078937931788, 10) 03-03 17:41:23.292: I/System.out(6454): MTProto#1001:MTProtoMessage: rpc_result#f35c6d01 03-03 17:41:23.292: I/System.out(6454): MTProto#1001:rpc_result: 5986604074642964484 03-03 17:41:23.292: I/System.out(6454): MTProto#1001:rpc_result: 5986604074642964484 #997275b5 03-03 17:41:23.292: I/System.out(6454): Scheduller:Prepare package: get_future_salts#b921bd04 of size 8 03-03 17:41:23.292: E/telegram(6454):
------------>onRpcResult[B@41fe2ad8
03-03 17:41:23.292: I/System.out(6454): Scheduller:Total size: 8 03-03 17:41:23.292: E/telegram(6454):
------------>boolTrue#997275b5
03-03 17:41:23.302: I/System.out(6454): MTProto#1001#Scheduller:Iteration: count: 1, confirm:1 03-03 17:41:23.302: I/System.out(6454): MTProto#1001#Scheduller:Building package 03-03 17:41:23.302: I/System.out(6454): MTProto#1001#Scheduller:Adding msg_ack: 1 03-03 17:41:23.302: I/System.out(6454): MTProto#1001#Scheduller:Adding package: #7 get_future_salts#b921bd04 (5986604078937931796, 11) 03-03 17:41:23.302: I/System.out(6454): MTProto#1001#Scheduller:Sending Package (5986604078937931800, 12) 03-03 17:41:23.322: D/dalvikvm(6454): GC_FOR_ALLOC freed 432K, 5% free 10247K/10712K, paused 17ms, total 18ms 03-03 17:41:23.322: I/System.out(6454): MTProto#1001#Scheduller:Forgetting message: #2 03-03 17:41:23.322: I/System.out(6454): MTProto#1001:MTProtoMessage: pong#347773c5 03-03 17:41:23.322: I/System.out(6454): MTProto#1001:pong: 1008804424396823222 03-03 17:41:23.322: I/System.out(6454): MTProto#1001#Scheduller:Forgetting message: #5 03-03 17:41:23.532: I/System.out(6454): MTProto#1001#Transport4:Start reading message: 148 03-03 17:41:23.532: I/System.out(6454): MTProto#1001:Decrypted in 3 ms 03-03 17:41:23.532: I/System.out(6454): MTProto#1001#BackOff:onSuccess 03-03 17:41:23.532: I/System.out(6454): MTProto#1001#BackOff:reset 03-03 17:41:23.532: I/System.out(6454): TransportRate:onConnectionSuccess #0 03-03 17:41:23.532: I/System.out(6454): TransportRate:Transport: #0 173.240.5.253:443 #1.0 03-03 17:41:23.532: I/System.out(6454): MTProto#1001:MessageArrived (#4): time: 1393864881 03-03 17:41:23.532: I/System.out(6454): MTProto#1001:MessageArrived (#4): seqNo: 4, msgId:5986604082617805825 03-03 17:41:23.532: I/System.out(6454): MTProto#1001#Transport4:Start reading message: 1124 03-03 17:41:23.532: I/System.out(6454): MTProto#1001:Ignoring messages #5986604080015130625 03-03 17:41:23.532: I/System.out(6454): MTProto#1001:MTProtoMessage: pong#347773c5 03-03 17:41:23.532: I/System.out(6454): MTProto#1001:pong: -6768130739083146993 03-03 17:41:23.532: I/System.out(6454): MTProto#1001#Scheduller:Forgetting message: #6 03-03 17:41:23.552: I/System.out(6454): MTProto#1001:Decrypted in 19 ms 03-03 17:41:23.552: I/System.out(6454): MTProto#1001:MessageArrived (#4): time: 1393864881 03-03 17:41:23.562: I/System.out(6454): MTProto#1001:MessageArrived (#4): seqNo: 4, msgId:5986604082737005569 03-03 17:41:23.572: I/System.out(6454): MTProto#1001:MTProtoMessage: future_salts#ae500895 03-03 17:41:23.572: I/System.out(6454): MTProto#1001#Scheduller:Forgetting message: #7
Hi @musol85 ! Can you publish your code for doing that ? I'm unable to even reach that point :/ For your problem, the doc says you have to use 109.239.131.195:80 as a server, not 173.240.5.253:443
At the time, 109.239.131.195:80 was offline. We were instructed to use the other server. However, we get the same response from both servers. As far as the code goes...
Main Class
import org.telegram.api.engine.*;
import org.telegram.mtproto.state.ConnectionInfo;
import org.telegram.tl.*;
public class RegisterClient {
private static final int REQUEST_TIMEOUT = 30000;
public static void main(String...args) {
try {
new RegisterClient().run();
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
public void run() throws Exception {
ConnectionInfo[] connections = new ConnectionInfo[]{
new ConnectionInfo(1, 0, "109.239.131.195", 80)
// new ConnectionInfo(1, 0, "173.240.5.253", 443)
};
MemoryApiState apiState = new MemoryApiState(connections);
TelegramApi api = new TelegramApi(apiState, new CpAppInfo(), new CpApiCallback());
TLSaveDeveloperInfo info = new TLSaveDeveloperInfo("Cosmic Push", "[email protected]", "15596407277", 38, "Oakhurst");
TLObject object = api.doRpcCallNonAuth(info, 120*1000, 1);
System.out.printf("");
}
}
MemoryApiState
import java.util.*;
import org.telegram.api.*;
import org.telegram.api.engine.storage.AbsApiState;
import org.telegram.mtproto.state.*;
public class MemoryApiState implements AbsApiState {
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;
public MemoryApiState(boolean isTest) {
connections.put(1, new ConnectionInfo[]{
new ConnectionInfo(1, 0, isTest ? "173.240.5.253" : "173.240.5.1", 443)
});
}
public MemoryApiState(ConnectionInfo[] connections) {
this.connections.put(1, connections);
}
@Override
public synchronized int getPrimaryDc() {
return primaryDc;
}
@Override
public synchronized void setPrimaryDc(int dc) {
primaryDc = dc;
}
@Override
public synchronized boolean isAuthenticated(int dcId) {
if (isAuth.containsKey(dcId)) {
return isAuth.get(dcId);
}
return false;
}
@Override
public synchronized void setAuthenticated(int dcId, boolean auth) {
isAuth.put(dcId, auth);
}
@Override
public synchronized 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 synchronized byte[] getAuthKey(int dcId) {
return keys.get(dcId);
}
@Override
public synchronized void putAuthKey(int dcId, byte[] key) {
keys.put(dcId, key);
}
@Override
public synchronized ConnectionInfo[] getAvailableConnections(int dcId) {
if (!connections.containsKey(dcId)) {
return new ConnectionInfo[0];
}
return connections.get(dcId);
}
@Override
public synchronized AbsMTProtoState getMtProtoState(final int dcId) {
return new AbsMTProtoState() {
private KnownSalt[] knownSalts = new KnownSalt[0];
@Override
public byte[] getAuthKey() {
return MemoryApiState.this.getAuthKey(dcId);
}
@Override
public ConnectionInfo[] getAvailableConnections() {
return MemoryApiState.this.getAvailableConnections(dcId);
}
@Override
public KnownSalt[] readKnownSalts() {
return knownSalts;
}
@Override
protected void writeKnownSalts(KnownSalt[] salts) {
knownSalts = salts;
}
};
}
@Override
public synchronized void resetAuth() {
isAuth.clear();
}
@Override
public synchronized void reset() {
isAuth.clear();
keys.clear();
}
}
TLSaveDeveloperInfo
import java.io.*;
import org.telegram.tl.*;
public class TLSaveDeveloperInfo extends TLMethod {
public static final int CLASS_ID = -757418007;
private String name;
private String email;
private String phone_number;
private int age;
private String city;
public TLSaveDeveloperInfo(String name, String email, String phoneNumber, int age, String city) {
this.setName(name);
this.setEmail(email);
this.setPhoneNumber(phoneNumber);
this.setAge(age);
this.setCity(city);
}
public TLBool deserializeResponse(InputStream stream, TLContext context)
throws IOException {
TLObject res = StreamingUtils.readTLObject(stream, context);
if (res == null) {
throw new IOException("Unable to parse response");
}
if ((res instanceof TLBool)) {
return (TLBool) res;
}
throw new IOException("Incorrect response type. Expected TLBool, got: " + res.getClass().getCanonicalName());
}
public void serializeBody(OutputStream stream)
throws IOException {
StreamingUtils.writeTLString(this.getName(), stream);
StreamingUtils.writeTLString(this.getEmail(), stream);
StreamingUtils.writeTLString(this.getPhoneNumber(), stream);
StreamingUtils.writeInt(this.getAge(), stream);
StreamingUtils.writeTLString(this.getCity(), stream);
}
public void deserializeBody(InputStream stream, TLContext context)
throws IOException {
this.setName(StreamingUtils.readTLString(stream));
this.setEmail(StreamingUtils.readTLString(stream));
this.setPhoneNumber(StreamingUtils.readTLString(stream));
this.setAge(StreamingUtils.readInt(stream));
this.setCity(StreamingUtils.readTLString(stream));
}
public String toString() {
return "register.saveDeveloperInfo#d2dab7e9";
}
@Override
public int getClassId() {
// TODO Auto-generated method stub
return -757418007;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhoneNumber() {
return phone_number;
}
public void setPhoneNumber(String phoneNumber) {
this.phone_number = phoneNumber;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
Thanks for the code ! I just tested and I'm getting a TimeoutException with both servers...
Nic0w, the timeouts are common... as of the time of writing this, they both appear to be up. That aside, the server is not sending out the SMS messages last I checked - last word is that ex3ndr is working to fix it.
in the mean time, you can use the API keys from the other projects.
Hmm ok, I'll try again then... Thanks for the info :) Le 14 mars 2014 07:53, "Jacob D. Parr" [email protected] a écrit :
Nic0w, the timeouts are common... as of the time of writing this, they both appear to be up. That aside, the server is not sending out the SMS messages last I checked - last word is that ex3ndr is working to fix it.
Reply to this email directly or view it on GitHubhttps://github.com/ex3ndr/telegram-api/issues/8#issuecomment-37621163 .
Are you trying in Linux or Windows?? I always get response in Windows and mac but not in linux. In linux I always have a timeOutException.
Hmm I always tested under Linux... Le 14 mars 2014 11:20, "dmasoft" [email protected] a écrit :
Are you trying in Linux or Windows?? I always get response in Windows and mac but not in linux. In linux I always have a timeOutException.
Reply to this email directly or view it on GitHubhttps://github.com/ex3ndr/telegram-api/issues/8#issuecomment-37633456 .
This won't address the fact that server still doesn't send the SMS message, or the intermittent timeouts, but you can now use the follow project to get started with registering an API key and eventually other examples.
https://github.com/SireInsectus/telegram-api-samples
I tried the above provided code but throwing the following error: D:\Java\Tomcat\webapps\ROOT\WEB-INF\classes>javac *.java RegisterClient.java:26: error: cannot find symbol TelegramApi api = new TelegramApi(apiState, new CpAppInfo(), new CpApiCallback()); ^ symbol: class CpAppInfo location: class RegisterClient RegisterClient.java:26: error: cannot find symbol TelegramApi api = new TelegramApi(apiState, new CpAppInfo(), new CpApiCallback()); ^ symbol: class CpApiCallback location: class RegisterClient Note: RegisterClient.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 2 errors
Please advise