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

Installing Blynk Local Server Win10

#1

I’m looking to install a Blynk local server, and spent all of yesterday believing I was doing exactly that, but I now think I merely loaded THIS jar file into Java 9. Added research has lead me to find THIS library for the local server which I now believe is the parent of the linked child above it. If this is the the case can, a Blynk mod edit the docs page /Blynk server link to direct us to the parent directory or provide a description why said link directs to the child.

Ok, now knowing that I did not in fact install the server, I seek some added instruction beyond what is provided in the ReadMe(dot)md file, most specifically as it relates to the following instruction;

Run the server on default 'hardware port 8442' and default 'application port 9443' (SSL port)

I don’t know how to “run” the server. Is there an executable file in one of the sub directories that would perform this action? Also, I don’t know how to stipulate either of the ports. Can someone fill in the blanks regarding this instruction? Thank you in advance.

0 Likes

#2

i only know how to do it in Raspberry Pi, but the instruction (the complete instruction) is this (the bit in bold type):

link

Run the server on default ‘hardware port 8442’ and default ‘application port 9443’ (SSL port)

java -jar server-0.31.0.jar -dataFolder /path

you type that into your CMD Java thingy, and it runs the server…

you have ot obviously change the -dataFolder /path to your data folder name…

1 Like

#3

I keep getting an error.

C:\Users\Jeffy>java -jar server-0.31.0.jar -dataFolder \C:\Users\Jeffy\Documents\Arduino\BlynkServer
Error: Unable to access jarfile server-0.31.0.jar
0 Likes

#4

Try entering the full path to the jar file. e.g. java -jar c:\documents\blabla\server.jar

0 Likes

#5

You made an error,

before you do what is said below make sure before going to start the server type in the command prompt :

cd the directory then where you have put your jarfile

e.g.

cd C:\Users\Jeffy\blynkserver


I recommend put the server in a folder and using this command in the command prompt:
"java -jar server-0.30.1.jar -dataFolder server_data " by typing this command the server will start and create a folder called server_data (in this folder you will have what the dataFolder command will put in it)

ok if you don’t want to do this I fixed your mistake below


C:\Users\Jeffy>java -jar server-0.31.0.jar -dataFolder \C:\Users\Jeffy\Documents\Arduino\BlynkServer

you shouldn’t put a back slash ’ \ ’ before ’ C:\Users\Jeffy\Documents\Arduino\BlynkServer ’

here is the correct command
C:\Users\Jeffy>java -jar server-0.31.0.jar -dataFolder C:\Users\Jeffy\Documents\Arduino\BlynkServer

Spot you mistake above


If you want to run the server like opening a application file then do this

create a text document in the same folder as in which the server.jarfile is
type this in the text

java -jar server-0.31.0.jar -dataFolder C:\Users\Jeffy\Documents\Arduino\BlynkServer

and save the file as autostart.bat (after saving heck and make sure that it is a bat file now and not a text file)

click the file whenever you want to run the server

0 Likes

#6

The instructions in Quick Local Server Setup/Github suggest to name the jar file before the path. Are you suggesting to name the path before the jar file?

The back slash before C; was generated in command prompt after I attempted to command the direction to the jar file and received the error.

In my studies, I came across some old posts with different strategies, one made a .cmd file that auto launches the server, but then the server requires that command prompt to remain open as long as the server is. Another approach creates Start, Stop and Restart files with .cmd, I presume for the obvious reasons, but I haven’t used those yet. I have also noticed that the Blynk jar files on Github are executable, so do I even need to use CMD outside of preparing the original configurations? My goal is to host my local server indefinitely to replace the cloud server, so save for maintenance and updates, I don’t ever intend to shut it down. Once I get better understanding for how to use the server, I will also begin learning the extended procedures to host the server from a Pi Zero W I have in storage, but I chose to start in a Windows environment because that is what I’m most familiar with.

0 Likes

#7

Ok, maybe I did mistakenly add the backslash before \C:, but I pasted in your instruction into CMD and hit the same error. Perhaps I need to issue the cd command first or create the server_data folder prior to trying this command?

java -jar server-0.31.0.jar -dataFolder C:\Users\Jeffy\Documents\Arduino\BlynkServer
0 Likes

#8

first you need the cd command (which means change directory)

0 Likes

#9

I believe I am getting the syntax wrong, can I manually create the folder with mouse clicks, then drag/drop the jar file to it, then use that as the directory, or does this all need to be performed in command prompt?

0 Likes

#10

just do this
put the jar file in a folder called blynk_server
open command prompt
use the cd command and put the directory of the jarfile aside of it e.g. cd C:\Users\Jeffy\Documents\blynk_server
then paste this command java -jar server-0.30.1 -dataFolder server_data
there you go your server has been started


                                                                  **OR**

use the cd command mentioned in the previous comment, then paste the code
java -jar server-0.30.1.jar -dataFolder C:\Users\Jeffy\Documents\Arduino\BlynkServer

note: make sure that you type the correct version in the command prompt, e.g. if your server jarfile’s version is 0.30.2 the make the following changes
java -jar server-0.30.2.jar -dataFolder C:\Users\Jeffy\Documents\Arduino\BlynkServer

I recommend doing the 1st method

0 Likes

#11

and if you close the command prompt you close the server too

0 Likes

#12

Here’s the results of my attempt of method 1

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Jeffy>cd C:\Users\Jeffy\Documents\blynk_server java -jar server-0.30.1 -dataFolder server_data
The system cannot find the path specified.

C:\Users\Jeffy>

0 Likes

#13

I moved the jar file into a folder called blynk_server as suggested, and placed that folder in Documents, but all of the other files remain in Documents/Arduino/blynkServer

0 Likes

#14

first make sure you make a folder in documents, name the folder as blynk_server then type in thecommand prompt the cd command then press enter after that type the java -jar command then press enter, okay ? both of those are different commands

0 Likes

#15

Before continuing, does the folder named blynk_server that is now in Documents also need to have all of the other files that came with downloading the server package from github, or is this folder just for the jar file? Originally, I had the jar file with all of the other accompanying files saved to the folder called blynkServer that was in Documents/Arduino/, so I now have 2 folders in different locations, 1 with the jar file and 2 with all of the other files.

I do not mean to appear as “slapping the hand that feeds” or at all unappreciative, but I think I am getting mixed up in all of the instructions, and coupled with the fact that I am brand new to servers and java and the command line(s), lack of original concise instruction from github, fragmented instructions from archived posts and increasing levels of frustrations I feel, I think it may also be frustrating you who is trying to help me get through this as well.

With all of that said, may I suggest/request that you take just a bit longer and share with me the step by step instructions I clearly need to get through this? I have the jar files and accompanying files that came with it, and I have Java 9.1 installed, but beyond that I can’t seem to do anything that produces a desired result. I made the server.properties and mail.properties files, and successfully launched the server when double clicking the executable, but anything involving the command prompt, I get nothing but failure, and I believe because I am misunderstanding the suggestions coming into this post, and likely because I am getting the syntax wrong. So if you make a typo, I will unwittingly type/paste that typo into the command prompt because I don’t know right from wrong.

0 Likes

#16

The zip file from GitHub has to be extracted and run from a single location. E.g. all the files and folders of the Blynk Server Release go into 1 folder.

Next to that there are several user createable settings files such as mail.properties and server.properties. They also need to reside where the Blynk server Jar file is.

The -dataFolder is where all user based data is stored. Your projects, auth codes, user files and so on. This can be anywhere and when starting the Jar file you can say where it has to put those files.

There are no executables with the Server release! The JAR file is a Java-compiled file which has to be run using the Java.exe (or javaw.exe) file on your system.

What is the output of java -version (when fired in a CMD?).

Please post a screenshot of where you extracted the files from GitHub. That should make things a bit clearer for us :slight_smile:

0 Likes

#17

Version of Java;

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Jeffy>java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

C:\Users\Jeffy>

The contents of my server folder and path (I moved the jar file back into it) Notice that the jar file is executable. I’ve confirmed that it launched after double clicking by opening Process Explorer (task manager-like app)

.

Edit - There are more files in the folder, POM etc and also the Start, Stop and Restart CMD executables.

Edit2 - my testing sketch.



//#define BLYNK_PRINT Serial    // Comment this out to     disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
//char auth[] = "CloudAUTHkey";   // Cloud Server
char auth[] = "LocalAUTHkey"; // Local Server
char ssid[] = "NetworkName";
char pass[] = "NetworkPassword";
byte arduino_mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress device_ip ( 10,   0,   0,  80);
IPAddress server_ip ( 10, 0, 0, 130 );      //IP of machine server runs on
IPAddress gateway_ip ( 10,   0,   0,   1);
IPAddress subnet_mask(255, 255, 255, 0);

#include <DHT.h>
#define DHTPIN 2 //pin 2 on ESP8266
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void readSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(true);

  Blynk.virtualWrite(V0, t); // virtual pin
  Blynk.virtualWrite(V1, h); // virtual pin
}

void setup()
{
  Serial.begin(115200);
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442); // Cloud Server
  Blynk.begin(auth, ssid, pass, server_ip, 8442); // Local Server
  
    // Setup WiFi network
  WiFi.config(device_ip, gateway_ip, subnet_mask);
  WiFi.begin(ssid, pass);

  // Setup Blynk
  Blynk.config(auth);
  while (Blynk.connect() == false) {
  }
  dht.begin();
  timer.setInterval(3000, readSensor);     //Read every 3 secs
}

void loop() {
  Blynk.run();
  timer.run();
}
0 Likes

#18

I think I’m making headway though am still getting errors. I figured out how to use the “cd” command to set the Current Directory, then my launch commands were producing different errors which I am comprehending as progress. Here are 2 screens of the command prompt and I will also try to attach the most recent portion of blynk.log regrading my most recent attempt. Hopefully someone can make sense of that bit of info.

19:10:10.844 INFO - Using data dir 'server_data'
19:10:10.938 INFO - Region : local. Host : 10.0.0.130.
19:10:11.688 INFO - Initializing gmail smtp mail transport. Username : REDACTED@gmail.com. SMTP host : smtp.gmail.com:587
19:10:12.110 INFO - Didn't find custom user certificates.
19:10:12.110 INFO - Didn't find Let's Encrypt certificates.
19:10:12.110 WARN - You didn't specified 'server.host' or 'contact.email' properties in server.properties file. Automatic certificate generation is turned off. Please specify above properties for automatic certificates retrieval.
19:10:12.110 WARN - ATTENTION. Server certificate paths (cert : 'C:\Users\Jeffy\Documents\Arduino\BlynkServer', key : 'C:\Users\Jeffy\Documents\Arduino\BlynkServer') not valid. Using embedded server certs and one way ssl. This is not secure. Please replace it with your own certs.
19:10:13.391 INFO - Hardware plain tcp/ip server listening at 8442 port.
19:10:13.391 INFO - Hardware SSL server listening at 8441 port.
19:10:13.391 INFO - Application server listening at 8443 port.
19:10:13.391 INFO - HTTP API and WebSockets server listening at 9443 port.
19:10:13.407 ERROR- Error initializing HTTPS API, WebSockets and Admin page, port 9443
java.net.BindException: Address already in use: bind
	at sun.nio.ch.Net.bind0(Native Method) ~[?:?]
	at sun.nio.ch.Net.bind(Unknown Source) ~[?:?]
	at sun.nio.ch.Net.bind(Unknown Source) ~[?:?]
	at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source) ~[?:?]
	at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:128) ~[server-0.31.0.jar:?]
	at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558) ~[server-0.31.0.jar:?]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1338) ~[server-0.31.0.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501) ~[server-0.31.0.jar:?]
	at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) ~[server-0.31.0.jar:?]
	at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:999) ~[server-0.31.0.jar:?]
	at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254) ~[server-0.31.0.jar:?]
	at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366) ~[server-0.31.0.jar:?]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[server-0.31.0.jar:?]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) ~[server-0.31.0.jar:?]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) ~[server-0.31.0.jar:?]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) ~[server-0.31.0.jar:?]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[server-0.31.0.jar:?]
	at java.lang.Thread.run(Unknown Source) [?:?]

0 Likes

#19

The 2nd CMD show a successfull start, more or less, except there are some ports already in use. Are you running any other software which could be responsible for that? Maybe try a reboot to make sure existing processes are killed (or use the taskmanager to kill any running Java processes).

The log file is a Unix standard, which means a WARNING is ok, not critical. ERROR is actually an error.

If you want to check which ports are in use you can do in cmd: netstat -an

2 Likes

#20

keep it up Jeffy - you are getting closer :slight_smile:

1 Like