CTBot icon indicating copy to clipboard operation
CTBot copied to clipboard

testConnection NOK, 1 year ago it worked fine

Open konig87nikkinakki opened this issue 3 years ago • 28 comments

Good evening, thank you for your library, i used 1 year ago and it worked fine. i did not upgraded any Library or Arduino IDE. This is my situation: Arduino IDE v1.8.12 (1 year ago i was using 1.8.6) ESP8266 V2.6.3 json library by Benoit Blanchon 5.13.3 CTBot by Stefano Ledda V1.3.0 (i know it's old but it worked fine). my SSID and PASSWORD are the same. My Telegram Bot is the same and i created a new one, afraid it was dead due to not log in for long time. My old sketch doesnt work anymore, it tell me "testConnection NOK". So i said "let's return to begin with easy", and i tried this script, that's your, from library, i only put 1 string to obtain IP address: `/* Name: lightBot.ino Created: 17/01/2018 Author: Stefano Ledda [email protected] Description: a simple example that do: 1) parse incoming messages 2) if "LIGHT ON" message is received, turn on the onboard LED 3) if "LIGHT OFF" message is received, turn off the onboard LED 4) otherwise, reply to sender with a welcome message nome bot: andradaacqua username bot: andradaacqua_bot */ #include "CTBot.h" #include <ESP8266WiFi.h> CTBot myBot;

String ssid = "Telecom-23382221"; // REPLACE mySSID WITH YOUR WIFI SSID String pass = MY_PASSWORD"; // REPLACE myPassword YOUR WIFI PASSWORD, IF ANY String token = "1739586950:AAHU_R-dSw2RpYlJPFaRhO2a3U4l6lO_XXX"; // REPLACE myToken WITH YOUR TELEGRAM BOT TOKEN uint8_t led = BUILTIN_LED; // the onboard ESP8266 LED.
// If you have a NodeMCU you can use the BUILTIN_LED pin // (replace 2 with BUILTIN_LED)

void setup() { // initialize the Serial Serial.begin(9600); //eraa 115200 delay(1000); Serial.println("Starting TelegramBot...");

// connect the ESP8266 to the desired access point
myBot.wifiConnect(ssid, pass);

// set the telegram bot token
myBot.setTelegramToken(token);

// check if all things are ok
if (myBot.testConnection())
	Serial.println("\ntestConnection OK");
else

{ Serial.println("\ntestConnection NOK"); Serial.println(WiFi.localIP());
}

// set the pin connected to the LED to act as output pin
pinMode(led, OUTPUT);
digitalWrite(led, HIGH); // turn off the led (inverted logic!)

}

void loop() { // a variable to store telegram message data TBMessage msg;

// if there is an incoming message...
if (myBot.getNewMessage(msg)) {

	if (msg.text.equalsIgnoreCase("LIGHT ON")) {              // if the received message is "LIGHT ON"...
		digitalWrite(led, LOW);                               // turn on the LED (inverted logic!)
		myBot.sendMessage(msg.sender.id, "Light is now ON");  // notify the sender
	}
	else if (msg.text.equalsIgnoreCase("LIGHT OFF")) {        // if the received message is "LIGHT OFF"...
		digitalWrite(led, HIGH);                              // turn off the led (inverted logic!)
		myBot.sendMessage(msg.sender.id, "Light is now OFF"); // notify the sender
	}
	else {                                                    // otherwise...
		// generate the message for the sender
		String reply;
		reply = (String)"Welcome " + msg.sender.username + (String)". Try LIGHT ON or LIGHT OFF.";
		myBot.sendMessage(msg.sender.id, reply);             // and send it
	}
}
// wait 500 milliseconds
delay(500);

}`

and this tell me "TestConnection NOK", thank to my string i can read ip that is 192.168.1.6, i can PING it with my PC and it answer, so it's connect to my router of course, i m sure. If i try to send commands "LIGHT ON" it doesnt work.i tried with other words (afraid of Capital, spaces..) but this still doesnt work. I know i have old library but before to upgrade i d like to know if i can fix problem, or if my JSON LIBRARY is not compatible with your library: this could be strange because 1 year ago this exactly same configuration did work. I m using a "new node mcu v3", 15 x2 pins, ESP8266MOD, black silicon board. Any help please...... could be ARDUINO IDE different version problem? i dont think so

konig87nikkinakki avatar Jun 20 '21 21:06 konig87nikkinakki

Hello, konig87nikkinakki, thanks for using the library. I know that if something works, you should leave it as is, but CTBot v 1.3.0 is very, very old heheheh For example, take a look here:

https://github.com/shurillu/CTBot/tree/1.4.1

A lot of things has happened so my suggestion is: update! You can update to the 2.1.5 (with Arduino IDE library updater) or use the new version 3.0.0 that you can find it in the v3.0.0 branch (I have to publish it!)

https://github.com/shurillu/CTBot/tree/v3.0.0

All member functions should be compatibles with the old versions, so just donwload the new version and compile it. If you don't have any restrictions about the ArduinoJson from B. Blanchon version, you can update his library too. There is an issue with the new ESP8266 toolchain that I have to fix, so keep with the 2.7.4

Let me know if you solve the issue!

Cheers,

Stefano

shurillu avatar Jun 21 '21 06:06 shurillu

Yesterday I noted the same behavior on my esp8266, it connects on wifi but testConnection always fails. This was working up to about a week ago

mad-b avatar Jun 21 '21 11:06 mad-b

Mmmm I'm trying to replicate the issue without luck (in other words: it simply works). Actually I'm using:

  • Arduino IDE 1.8.15
  • ESP8266 toolchain 2.7.4
  • ArduinoJson 6.18.0
  • CTBot library 3.0.0
  • NodeMCU 1.0 (but I think it doesn't really matter)

Stefano

P.S.: in CTBotDefines.h try to enable all logs by editing the define

#define CTBOT_DEBUG_MODE CTBOT_DEBUG_ALL

shurillu avatar Jun 21 '21 13:06 shurillu

Hi Shurillu thank you for fast reply. i installed your last library, but keep others old: Arduino IDE v1.8.12 ESP8266 V2.6.3 json library by Benoit Blanchon 5.13.3

AND THIS IS WORKING NOW! so maybe it was the old library: for sure telegram changed something in Bot and you updated it in newer library. i read some old issues, you wrote about a new ip from Telegram server: am i right? if you like, if IP changes, we can write it into a DynDNS Professional Account and put dyndns link into the library, so if IP changes again we can modify and update it from dyndns and make it back to work. Tell me...

konig87nikkinakki avatar Jun 21 '21 14:06 konig87nikkinakki

hmm.. sorry... again. i didnt touched sketch during this day. yesterday night it worked with new library as i told you but today again error "testConnection NOK". Bot is the same of course. i created another one just to test but it's not the problem. i'm using as i said a nodemcu v3 , 30pin (15+15), black silicon. do you think it's a nodemcu problem? i really don't think so, maybe i should:

  1. buy a better ESP32 instead of nodemcu
  2. upgrade json library
  3. update ESP8266 arduino core, i m using 2.6.3 i see there is v3.0.0 Tell me what do you think about, i would not upgrade because i m afraid of errors if i need to downgrade to old in future. why yesterday did it worked and not today? what do you think about? shall i burn this nodemcu into a fireplace? :-D

konig87nikkinakki avatar Jun 21 '21 20:06 konig87nikkinakki

Hello konig87nikkinakki, my advice is: try to enable all debug console messages. To do it, find the file CTBotDefines.h, open it and modify

#define CTBOT_DEBUG_MODE CTBOT_DEBUG_DISABLED

in this way

#define CTBOT_DEBUG_MODE CTBOT_DEBUG_ALL

Recompile and upload the sketch, open the serial monitor and take a look to the messages. If you got errors, please put here all the log messages.

VERY IMPORTANT: take care when you update the ESP8266 Arduino core, because the v3.0.0 is NOT compatible with the library (I have to do some tweaks). The last confirmed ESP8266 Arduino core version is v2.7.4

Please, let me know!

Cheers

Stefano

shurillu avatar Jun 22 '21 05:06 shurillu

Hello @shurillu. I got the same issue from yesterday. From your advice, I got this information in my Serial Monitor

ESP8266 with https verification Unable to connect to Telegram server getNewMessage error: ArduinoJson deserialization error code: EmptyInput

I use PlatformIO with CTBot Ver. 2.1.4 and ArduinoJson Ver. 6.18.0

GhaniyKie avatar Jun 22 '21 06:06 GhaniyKie

Same issue here. All my devices went silent yesterday after the last message at 15:18 UTC

I'll try to switch to 3.0.0

seikobu avatar Jun 22 '21 07:06 seikobu

Hello. Same issue starting from yesterday: unable to connect to server. Maybe they changed ip? ESP8266, CTBot ver. 3.0.0, ArduinoJson ver. 6.18.0, core 2.7.4

cpalf avatar Jun 22 '21 08:06 cpalf

if it's a ip problem, maybe it's time to chain to a dyndns pro account ;-) but everytime it fails we have to upgrade it manually ...it s boring

konig87nikkinakki avatar Jun 22 '21 09:06 konig87nikkinakki

Ok I should have found the problem (or I guess so!)

Inside the library, it is possible to use the symbolic name or the IP of the Telegram Server used for handling bots. All connection to this server must be done by HTTPS protocol and ther are some checks that the library "should" do. With the ESP8266 these checks are done by using the Telegram Server fingerprint. It seems that now if we using the Telegram Server IP to make connections, the fingerprint verification fails and it is impossible to establish a connection to the telegram server. There are two possibilities:

  • using the useDNS(true) member function in order to use the Telegram Server symbolic name
  • disabling the fingerprint verification by modifing the following row in the file CTBotDefines.h

#define CTBOT_USE_FINGERPRINT 0

(set it to zero).

This should solve the issue, let me know!

Cheers

Stefano

shurillu avatar Jun 22 '21 12:06 shurillu

incredible work, stefano! I'll try that after work, expect my feedback in around 3h

seikobu avatar Jun 22 '21 12:06 seikobu

Hello. Same issue starting from yesterday: unable to connect to server. Maybe they changed ip? ESP8266, CTBot ver. 3.0.0, ArduinoJson ver. 6.18.0, core 2.7.4

Stefano wrote "v3.0.0 is NOT compatible with the library" but it's not your first problem: i have older and the same problem. it's sad, because this is a very goood and flexible Library! the best for telegram bot i ve always seen! Stefano if you need any help we can do, we will. this evening i ll read error and write you details. i just seen you answered right now! :-D We're typing in the same moment. i will try this evening after i finish to be slave at work.

konig87nikkinakki avatar Jun 22 '21 12:06 konig87nikkinakki

I have this same issue since yesterday (monday morning) with 3 devices, each one with its own token. it happened at the same time for the 3 of them. Good that I found this info. I am gooing to test w v3 of the library and see how it goes.

albertoalonso1 avatar Jun 22 '21 17:06 albertoalonso1

Ok I should have found the problem (or I guess so!)

Inside the library, it is possible to use the symbolic name or the IP of the Telegram Server used for handling bots. All connection to this server must be done by HTTPS protocol and ther are some checks that the library "should" do. With the ESP8266 these checks are done by using the Telegram Server fingerprint. It seems that now if we using the Telegram Server IP to make connections, the fingerprint verification fails and it is impossible to establish a connection to the telegram server. There are two possibilities:

  • using the useDNS(true) member function in order to use the Telegram Server symbolic name
  • disabling the fingerprint verification by modifing the following row in the file CTBotDefines.h

#define CTBOT_USE_FINGERPRINT 0

(set it to zero).

This should solve the issue, let me know!

Cheers

Stefano

unlucky so far. Tried both methods, also in combination ^^'

Using Arduino 1.8.13 ArduinoJson 6.17.3 CTBot 2.1.5

A short test with 3.0.0 didn't compile, but I try to adapt my code to it tomorrow.

seikobu avatar Jun 22 '21 19:06 seikobu

Hey my problem (see title of this issue) seems to be solved, see solution at issue #85 it works for me, hope for tomorrow. here is my personal situation:

  1. Arduino ver 1.8.12
  2. libreria CTbot ver 2.1.5
  3. JSON LIBRARY by Benoit Blanchon ver 6.18.0
  4. core di ESP8266 (programmatore) ver 2.6.3 💯

konig87nikkinakki avatar Jun 22 '21 20:06 konig87nikkinakki

Hey my problem (see title of this issue) seems to be solved, see solution at issue #85 it works for me, hope for tomorrow. here is my personal situation:

  1. Arduino ver 1.8.12
  2. libreria CTbot ver 2.1.5
  3. JSON LIBRARY by Benoit Blanchon ver 6.18.0
  4. core di ESP8266 (programmatore) ver 2.6.3 💯

Could you drop the syntax so I can try it? Thanks @konig87nikkinakki

mhilmanmaulana avatar Jun 23 '21 05:06 mhilmanmaulana

Following the #85 issue, it is ready to download a quick fix for the V3.0.0 branch. This evening I'll do the same for the old v2.x.x

Stefano

shurillu avatar Jun 23 '21 07:06 shurillu

Following the #85 issue, it is ready to download a quick fix for the V3.0.0 branch. This evening I'll do the same for the old v2.x.x

Stefano

thank you, hope everything is gonna be okay.

mhilmanmaulana avatar Jun 23 '21 08:06 mhilmanmaulana

Ok, I did what you said and same result "Bot nor connected". by the way, a device I made with this Library, 2 years ago, is having the same problem. Greetings, Al.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

El mié, 23 jun 2021 a las 4:46, mhilmanmaulana @.***>) escribió:

Following the #85 https://github.com/shurillu/CTBot/issues/85 issue, it is ready to download a quick fix for the V3.0.0 branch. This evening I'll do the same for the old v2.x.x

Stefano

thank you, hope everything is gonna be okay.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shurillu/CTBot/issues/84#issuecomment-866651519, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHPKX5I7Z5YXY74GHK74EZLTUGNOVANCNFSM47AONSQA .

albertoalonso1 avatar Jun 23 '21 13:06 albertoalonso1

I published a new release (2.1.6) with the changes suggested in the #85 issue and some others minor bugs

Stefano

shurillu avatar Jun 23 '21 16:06 shurillu

If it helps you, this morning I try a sketch with the Brian Lough Library and I think the same thing happens. Al.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

El mié, 23 jun 2021 a las 12:49, Stefano Ledda @.***>) escribió:

I published a new release (2.1.6) with the changes suggested in the #85 https://github.com/shurillu/CTBot/issues/85 issue.

Stefano

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shurillu/CTBot/issues/84#issuecomment-866999759, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHPKX5N3ZDTIY5FMIX64E4TTUIF7ZANCNFSM47AONSQA .

albertoalonso1 avatar Jun 23 '21 17:06 albertoalonso1

I published a new release (2.1.6) with the changes suggested in the #85 issue and some others minor bugs

Stefano

Thank you so much.

mhilmanmaulana avatar Jun 24 '21 01:06 mhilmanmaulana

Ok, Problem Solved. I change to release 2.1.6 and connection is OK, Thanks for your help and contact. Al.

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Libre de virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

El mié, 23 jun 2021 a las 21:42, mhilmanmaulana @.***>) escribió:

I published a new release (2.1.6) with the changes suggested in the #85 https://github.com/shurillu/CTBot/issues/85 issue and some others minor bugs

Stefano

Thank you so much.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shurillu/CTBot/issues/84#issuecomment-867267678, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHPKX5NUEHQTIAVCOR3L26LTUKEPFANCNFSM47AONSQA .

albertoalonso1 avatar Jun 24 '21 13:06 albertoalonso1

Thank you Alberto for your feedback!

I'll wait a week and if there are no other problems, I'll close this issue.

Stefano

shurillu avatar Jun 24 '21 13:06 shurillu

Yes, 2.1.6 and the thing got back to life. Thanks for the fix, Stefano. Att. Lissandro

mad-b avatar Jun 25 '21 15:06 mad-b