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

HOw to run localserver on smartphone using termux

Hello, comrades

I can now run a local server on my smartphone

but back to the beginning

First you need to install termux, can be found in google playmarket.
Then open termux and install packages.
list of packages to install: wget, openssl-tools, proot.

pkg install proot

And time to install Java, info taken from github


here is the command to install

wget https://raw.githubusercontent.com/MasterDevX/java/master/installjava && bash installjava

on the phone java will not start without the proot package. so we have to pretend that we are a superuser.

Just write in concole:
proot -0


check if java works
java -version

if everything works, then load the server file
wget "https://github.com/blynkkk/blynk-server/releases/download/v0.41.13/server-0.41.13-java8.jar"

Before starting, you need to make a certificate for the server, otherwise it will not start
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.key -out cert.crt

and then write them in the server.propeties file. And add the file storage path
should look something like this

server.ssl.cert=cert.crt
server.ssl.key=key.key
server.ssl.key.pass=
data.folder=blynkdata/

always run proot before starting the server.
proot -0

then
java -jar server-0.41.13-java8.jar

???
Profit?
Devide was Honor 9X with Android 10

3 Likes

Ещё сделал скрипт на автозапуск, наслаждайте, есть две команды start и stop. Можно поместить название скрипта в файл .profiles чтобы запускался каждый раз при запуске терминала, сервер запущен под командой nohup так что привязки к терминалу нет и будет работать в фоне даже после logout.

копируем код в файл например top.sh пишем в консоль
chmod 700 top.sh
и можно пользоваться

#!/bin/bash
pidjava=$(ps -aux | grep "[j]dk8" | awk '{print $2}')

case $1 in

        start)
         #echo "case start"
         if [ $pidjava > 0 ]
         then 
         echo "server online PID $pidjava"
         else
         echo "server offline"
         echo "starting"
         nohup proot -0 java -jar server.jar &
         date >> nohup.out
         sleep 10
         tail -n 4 nohup.out
         tail -n 15 logs/blynk.log | grep "Region"
         echo "ready"

         fi

         ;;

        stop)
         #echo "case stop"
         if [ $pidjava > 0 ]
         then
         kill $pidjava
         sleep 2
         tail nohup.out
         else 
         echo "404"
         fi
         ;;



        *)
        # echocase empty"
         exec ./top.sh start
         ;;
esac

exit 0

Is it possible to run the local server and the Blynk App on the same smartphone?

Greetings to the forum.

Yes, just write in blynk app “localhost” ipaddress