Created a bot, started using the telegram api project is going with the help of maven, he threw a dependency
<dependency> <groupId>org.telegram</groupId> <artifactId>telegrambots</artifactId> <version>3.5</version> </dependency>
Then I partially implemented the onUpdate, getBotUsername and getBotToken methods.
@Override public void onUpdateReceived(Update update) { if(update.hasMessage() && update.getMessage().hasText()){ SendMessage message = new SendMessage().setChatId(update.getMessage().getChatId()); Message msg = update.getMessage(); String text = ""; message.setText(text); } else if(update.hasCallbackQuery()){ } } @Override public String getBotUsername() { return "name"; } @Override public String getBotToken() { return "token"; }
in the main method
ApiContextInitializer.init(); TelegramBotsApi telegramBotsApi = new TelegramBotsApi(); try { telegramBotsApi.registerBot(new ConnectToTelegramm()); } catch (TelegramApiRequestException e) { e.printStackTrace(); }
and then error pops up
фев 17, 2019 8:20:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.telegram.org:443: Connection reset фев 17, 2019 8:20:34 AM org.apache.http.impl.execchain.RetryExec execute INFO: Retrying request to {s}->https://api.telegram.org:443 фев 17, 2019 8:20:35 AM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.telegram.org:443: Connection reset фев 17, 2019 8:20:35 AM org.apache.http.impl.execchain.RetryExec execute INFO: Retrying request to {s}->https://api.telegram.org:443 фев 17, 2019 8:20:35 AM org.apache.http.impl.execchain.RetryExec execute INFO: I/O exception (java.net.SocketException) caught when processing request to {s}->https://api.telegram.org:443: Connection reset фев 17, 2019 8:20:35 AM org.apache.http.impl.execchain.RetryExec execute INFO: Retrying request to {s}->https://api.telegram.org:443 org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error executing setWebook method at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:55) at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:120) at Bots.main(Bots.java:15) Caused by: java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) at java.net.SocketInputStream.read(SocketInputStream.java:141) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at sun.security.ssl.InputRecord.read(InputRecord.java:503) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396) at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355) at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359) at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:43) ... 2 more
Tell me what am I doing wrong?