Invalid Auth Token on local Server (ESP8266 / NodeMCU)

#define BLYNK_DEBUG
#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include <TimeLib.h>  //download at https://github.com/PaulStoffregen/Time
#include <BlynkSimpleEsp8266.h>
#include <ArduinoOTA.h>

// your settings -------
char ssid[] = "(.)(.)";
char pass[] = "Welcome2(.)(.)";
char auth[] = "​5fbc5f8ca25746958eb8da76eb8960f8";

void setup() {
  Serial.begin(115200);
  //Blynk.config(auth);
  //Blynk.connectWiFi(ssid, pass);
  //Blynk.disconnect(); 
  
  Serial.println("connecting to Blynk Server");
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,0,59));
  Serial.println("Connection etablished!");
}

void loop() {
  ArduinoOTA.handle();
  Blynk.run();
}

Try this simpler sketch…

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "​5fbc5f8ca25746958eb8da76eb8960f8";
char ssid[] = "(.)(.)";
char pass[] = "Welcome2(.)(.)";
char server[] = "192.168.0.59";
int port = 8080;

void setup() {
  Serial.begin(115200);
  Serial.println("Connecting to Blynk Server");

  WiFi.begin(ssid, pass); 
  Blynk.config(auth, server, port);
  Blynk.connect();
}

void loop() {
  Blynk.run();
}

BLYNK_CONNECTED() {  // Run this function when connected to server
  Serial.println("Connection established!");
}

Login timeout.

I changed the Port to 8442 and get “Invalid token” again.

Here the device in my blynk admin:

Why?.. the proper port in the script to use is 8080.

What is your Local Server version?

my server version is still 0.33.1

regards hills8

You need to keep current with all updates on App, Server and Libraries… they are all intertwined and leaving one or more behind will cause these types of issues.

NOTE: you will need to make port changes to App (9443) and sketches (8080)… possibly even to any port forwarding you may have.

It is important to keep checking any new Announcements topics… saves us time troubleshooting something due to old components.

Okay, will Update all. Thank you

Okay, Library updated to v 0.5.2
server updated to 0.34.1
port changed back to 8080

[242847] Connecting to 192.168.0.59:8080
[242850] <[02|00|01|00]#[E2|80|8B]5fbc5f8ca25746958eb8da76eb8960f8
[242857] >[00|00|01|00|09]
[242857] Invalid auth token

AND i am not able to open the admin page anymore. I tired:
```cpp sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 ````
and open following pages
(http://192.168.0.59:7443/admin)
(http://192.168.0.59:8080/admin)
(http://192.168.0.59:80/admin)
hills8

http://192.168.0.59:9443/admin

ERR_EMPTY_RESPONSE

https:// i missed that one…

https://192.168.0.59:9443/admin/.
HTTP ERROR 404

Ok, I’m out … :flushed:

but the server seems to listen to that port:

sudo netstat -tlpn Aktive Internetverbindungen (Nur Server)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 462/sshd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 585/mysqld
tcp6 0 0 :::22 :::* LISTEN 462/sshd
tcp6 0 0 :::8440 :::* LISTEN 405/java
tcp6 0 0 :::8441 :::* LISTEN 405/java
tcp6 0 0 :::9443 :::* LISTEN 405/java
tcp6 0 0 :::8080 :::* LISTEN 405/java

hills8

80|8B this seems to be some invisible chars before your auth token. Try to remove your token and copy again without “hidden” chars.

Unicode copy/paste error?
U+200B ​ 0xe2 0x80 0x8b <-- matches the pattern

EDIT: U+200B = Zero width space…

okay, copied the whole script in notepad++
copied than in a new script.ino and uploaded it.

debug message changed to someting like:
[02|00|01|00]?>5fbc5f8ca25746958eb8da76eb8960f8 (maybe a little bit differnt)

i changed the
char auth[] = “5fbc5f8ca25746958eb8da76eb8960f8”;
to
char auth[] = ‘5fbc5f8ca25746958eb8da76eb8960f8’;
and back to:
char auth[] = “5fbc5f8ca25746958eb8da76eb8960f8”;

now the device is connecting succesful!

Thank you for that!!!

…but the admin page is still not accessible :frowning:

hills8

check your server.properties and compare with the default one (from git for example)

1 Like

seems to be correct

#https and web sockets port
https.port=9443

Try to remove server.properties and restart the server. Add only properties your really know and need.