BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Does gmail "send token" work with Docker local server?

Hi all,

Regarding the localserver running in a Docker container:

Firstly:
Before I waste anymore time than I already have, is it even possible to email the token from the app to my gmail?

I notice there is a github ‘improvement’ tagged in @Dmitriy 's name.

Secondly:
On the Web admin page https://192.168.1.99:9443/admin I edit the mail.properties file, but it never saves. Is it even used?

Thanks for any tips!

PS here’s a link to the project if anyone’s interested

Here’s the Dockerfile in case there is an issue there:

FROM adoptopenjdk/openjdk11
MAINTAINER Graham Garner <garner.gc@gmail.com>

#RUN apt-get update 
#RUN apt-get install -y apt-utils
#RUN apt-get install -y default-jdk curl

ENV BLYNK_SERVER_VERSION 0.41.10
RUN mkdir /blynk
RUN curl -L https://github.com/blynkkk/blynk-server/releases/download/v${BLYNK_SERVER_VERSION}/server-${BLYNK_SERVER_VERSION}.jar > /blynk/server.jar

# Create data folder. To persist data, map a volume to /data
RUN mkdir /data

# Create configuration folder. To persist data, map a file to /config/server.properties
RUN mkdir /config && touch /config/server.properties
VOLUME ["/config", "/data/backup"]

# IP port listing:
# 8080: Hardware without ssl/tls support
# 9443: Blynk app, https, web sockets, admin port
EXPOSE 8080 9443

WORKDIR /data
ENTRYPOINT ["java", "-jar", "/blynk/server.jar", "-dataFolder", "/data", "-serverConfig", "/config/server.properties"]

I played around with the IOTStack stuff for a while, and I’m fairly certain I managed to get the gmail stuff working, but I couldn’t get the data storage to work so I gave up.
In the end I did a fresh install of the non-dockerised version of Blynk server and TBH it’s actually much easier neater that way.

I can’t get that to work, even with the non-dockerised version of local server, I just manually created the server.properties and mail.properties files in the same location as the .jar file and ignore the admin page for editing them.

Pete.

1 Like

Hi Pete, what data storage are you referring to?

Now I look back at my notes i agree it does seem a lot simpler to run the non-docker version.

That is good to know, it’s been driving me mad! Other than the email (which is probably my server.properties being wrong, I need to sort that) it seems to be working fine.

Raw data storage, so that Superchart can be used…

Probably mail.properties.
Also, you have to enable “less secure apps” in your gmail account. I actually just created a new gmail account that is just for Blynk dispatcher emails and changed the security on that account.

I also like to use a Pi web based admin system called Webmin. It makes the Pi admin much simpler than having g to keep looking-up the commands to do simple stuff like checking for updates - but Webmin doesn’t seem able to run in a Docker container, and can’t help you to manage your dockerised apps.
I have to say that I felt much more in control when I switched from the IOTStack setup to the regular install, and that was after putting in quite a lot of time to the dockerised setup.

Pete.

Ah yes I forgot about Supercharts. I’m using influxdb/grafana now but still like a little Superchart.

I think mail.properties is ok, and I am using an App password. The log points to server.properties being the issue.

I like the Docker setup myself, I just think the guy who set up the Blynk container did not actually use Blynk, so there is some more config to do. Maybe I will get there.
Cheers

I’m using Blynk local server in a Docker container on a Synology NAS. It was a right pain to set up, but now it’s rock solid. May be of assistance to you…

My Docker container is called ‘Blynk’ and persistent files are in /docker/Blynk/ on the Synology

I can’t remember what I tweaked that finally made it work, but this is my setup that works:
My ‘Execution Command’ is:
java -jar /blynk/server.jar -dataFolder /data -serverConfig /config/server.properties -mailConfig /data/mail.properties
Mounted Files/Volumes
Folder: docker/Blynk
Mount Path: /data
(This is your main persistent Blynk folder. Blynk will populate it with bits and pieces on first run, and then update over time)
File: docker/Blynk/single_token_mail_body.txt
Mount Path: /config/single_token_mail_body.txt
(This lets you define boilerplate for the token email)
File: docker/Blynk/server.properties
Mount Path: /config/server.properties
(Self explanatory)

The folder structure and files (mail.properties, single_token_mail_body.txt and server.properties), need to have been created before you run Blynk. They sit in my docker/Blynk folder (the /data mount path).

If you need any more let me know.
Graham

Hi Graham,

Thank you for the info, much appreciated. I’ve been working on it and seem to have it working, I wrote a new write up for the project, although it does need fine tuning…(link)

This part I have not looked at yet, mine seems to work without it so far. What is the purpose of that file?

When Blynk sends a ‘token email’, that email contains just the token, no explanation or anything.

Blynk uses any text you put in ‘Single_token_mail_body.txt’ as extra text in each ‘token email’ it sends. I think it’s more for when the email goes to someone you’ve shared a project with, so you can include instructions etc.

I just use it for neatness (and to get it working in case I need it one day!)
Hope that helps

Yes that’s pretty nice, thanks for the explanation. I will for sure look at that…

Pete, I’ve enabled raw storage on the local server and it ‘seems’ to be working with Superchart, am I missing something? Does it not retain or soemthing?

PS looks like the admin panel does not work “on purpose” :wink:
LINK

Sorry, should have read your write up first. I’m not familiar with IOTstack, but I think Docker is platform agnostic.
If you want your .properties file to persist over reboots, you can mount the /config and /data folders outside the docker container (or mount individual .properties files, as in my first reply to you). When Blynk first runs it checks for the existence of the .properties files. If they are present it reads their instructions. If the files are not present Blynk creates them.

I would say that the Blynk admin page accesed through ‘https://youripaddress:9443/admin’ has never worked well for me, so I just edit .properties files directly. Those files are obviously hosted outside the docker container, so persist through reboots.

For info (and if you need help) I have automatic LetsEncrypt certificates, and also run NodeRed, and Mosquitto (MQTT) in other docker containers. I also have ‘quite a few’ Sonoff devices flashed with Tasmota.

Graham

Did you install Postgresql in its own dockerised container, using the setup script on the IOTStack GitHub page, or simply follow the instructions on the Blynk server page for a regular install?

Pete.

That all matches with what I have found, I have already mapped the data and config folder and it persists fine.

I did not find that Blynk created the files if missing though, I had to create a script to create them at the time of Docker container build. If they did not exist the container would not start.

Good to know yours works the same way.
Thank you :slight_smile:

None of the above, I just enabled raw data storage :slight_smile: Does the data not persist on the Superchart? Or are you storing it for another reason? I’m not sure really as I don’t use them for much.
I feel I am about to get school’d :laughing:

Personally I recently starting using this method:
mqtt>node red>influxdb>grafana.

Seems it is optional: Historical data, own server - default feature, or DB needed?
As I use a M.2 SATA drive I have plenty of space, and not worried about read/writes wearing out an SD card.

A negative is that it increases the size of my IOTstack Dropbox daily backup.

I’ve only been injecting some small data points so far, would be interesting to see how large the files get after a while. I’ll start logging a temperature sensor for now.

image

Okay, interesting.
Superchart was only showing live data until I enabled raw data storage, but I’m not sure why now!

Pete.

I thinks that’s correct Pete. You maybe took the additional step of setting up Postgresql instead of using local storage. I read the guide and it put me off to be honest. The github may be out of date.

I actually have this setup:

enable.db=false
enable.raw.db.data.store=true

On another note, I wonder if changing the settings in the Superchart widget changes the way the data is stored in the file system.

Yes thinking about it you’re right. Blynk creates them, but not in the folders you have mounted. As soon as you create them in the mounted folders, Blynk ‘prefers’ those files over the Blynk created files. I did have to tweak a lot to get it working, including deleting quite a few Docker containers (Synology doesn’t let you edit the ‘execution command’ after you’ve created the container, so you have to start from scratch each time). My Blynk starting without complaining of missing files might have been an artifact of all the tweaking I did. Sorry if I mislead.