0

This code worked until last week. Now I'm getting a handshake_failure error and I dont know why exactly, some help would be appreciated!

String urlString = "https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s";

String channelName = "-100123456789"; // ex.

urlString = String.format(urlString, apiToken, channelName, message);

URL url = new URL(urlString);
URLConnection conn = url.openConnection();

StringBuilder sb = new StringBuilder();
InputStream is = new BufferedInputStream(conn.getInputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String inputLine = "";
while ((inputLine = br.readLine()) != null) {
    sb.append(inputLine);
}
String response = sb.toString();
Kevin Hernandez
  • 1,270
  • 2
  • 19
  • 41
erosdet
  • 1
  • 1
  • Does this answer your question? [Received fatal alert: handshake\_failure through SSLHandshakeException](https://stackoverflow.com/questions/6353849/received-fatal-alert-handshake-failure-through-sslhandshakeexception) – Aleksandr Belugin Feb 11 '20 at 15:31

1 Answers1

0

Since last week telegram stopped using TLS 1.1 and 1.0 and is only supporting TLS 1.2 now so you would need to upgrade.

Please note that the Bot API only accepts incoming TLS 1.2 connections (or higher). Kindly update your bot if it was using the outdated TLS 1.0 or TLS 1.1 protocol.

https://t.me/BotNews/51

painor
  • 1,119
  • 1
  • 8
  • 25