[SOLVED] Local sever with USB connection issues

Basically what i have so far is:

  • Local server running on RPI v3 (connected via ethernet)
  • Arduino Mega running through USB
  • and it will be controlled via the Apple Blynk app

When i use the Blynk cloud everything is happy and i’m basically Harry Potter turning everything on and off from my phone. :sunglasses:
But when i try to do it via the local server, i’m more of a muggle… :disappointed_relieved: also quick side note i have no experience with RPI, just thought it would be a great was to learn.

I’m able to start my server as per the docs (although that was a mission, i needed to install socat before it would work) and when i run the following commend i get the expected result:



Blynk Server 0.41.1-SNAPSHOT successfully started.
All server output is stored in folder '/home/pi/logs' file.

now as for the Blynk script when i use the cloud i run the following which works:

Resetting device /dev/ttyACM0...
Warning: /home/pi/Arduino/libraries/Blynk/scripts/certs/fullchain.crt not found. Skipping server verification (connection may be insecure)!
[ Press Ctrl+C to exit ]
Connecting: FILE:/dev/ttyACM0,raw,echo=0,clocal=1,cs8,nonblock=1,b9600 <-> openssl-connect:blynk-cloud.com:8441,verify=0,nodelay
2018/12/15 10:16:02 socat[4660] N opening character device "/dev/ttyACM0" for reading and writing
2018/12/15 10:16:02 socat[4660] N opening connection to AF=2 45.55.96.146:8441
2018/12/15 10:16:02 socat[4660] N successfully connected from local address AF=2 138.77.220.56:35130
2018/12/15 10:16:03 socat[4660] N option openssl-verify disabled, no check of certificate
2018/12/15 10:16:03 socat[4660] N SSL connection using ECDHE-RSA-AES128-GCM-SHA256
2018/12/15 10:16:03 socat[4660] N SSL connection compression "none"
2018/12/15 10:16:03 socat[4660] N SSL connection expansion "none"
2018/12/15 10:16:03 socat[4660] N starting data transfer loop with FDs [5,5] and [6,6]

but when i try to adjust that the ip of the computer and port 9443(from what i found it the forum i need to use that port) i get:

Resetting device /dev/ttyACM0...
Warning: /home/pi/Arduino/libraries/Blynk/scripts/certs/fullchain.crt not found. Skipping server verification (connection may be insecure)!
[ Press Ctrl+C to exit ]
Connecting: FILE:/dev/ttyACM0,raw,echo=0,clocal=1,cs8,nonblock=1,b9600 <-> openssl-connect:138.77.220.56:9443,verify=0,nodelay
2018/12/15 10:17:43 socat[4695] N opening character device "/dev/ttyACM0" for reading and writing
2018/12/15 10:17:43 socat[4695] N opening connection to AF=2 138.77.220.56:9443
2018/12/15 10:17:43 socat[4695] E connect(6, AF=2 138.77.220.56:9443, 16): Connection refused
2018/12/15 10:17:43 socat[4695] N exit(1)
Reconnecting in 3s...

if i run IPconfig i have the follwoing info:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 138.77.220.56  netmask 255.255.254.0  broadcast 138.77.221.255
        

Now i’ve tried both my local and public with no luck, quickly becoming way over my head :sweat_smile:

Noob level 10000000+

thank you in advance

it actually should be port 8080 which is the default HARDWARE port (AKA all our microcontroller thingys) for basic TCP communication.

Port 9443 is for the App and for the Device if it is running in SSL and requires the appropriate library as well.

1 Like

Thank you for that @Gunner, think i might need to read the doc again and try to understand which port is for what.

now i’ve made the change, just wanting to confirm my output is correct:

2018/12/15 10:37:57 socat[4895] N opening character device "/dev/ttyACM0" for reading and writing
2018/12/15 10:37:57 socat[4895] N opening connection to AF=2 138.77.220.56:8080
2018/12/15 10:37:57 socat[4895] N successfully connected from local address AF=2 138.77.220.56:60942
2018/12/15 10:37:57 socat[4895] E SSL_connect(): Success
2018/12/15 10:37:57 socat[4895] N exit(1)
Reconnecting in 3s..

is it normal to keep cycling like this?

This still looks like you are using som SSL setup in the sketch?? I don’t bother with SSL so am unsure

if you’re referring to the Arduino sketch, i’m just using the example USB sketch in library 0.5.4, i might have a look through the forums to see if i cant find anything else.

Also one last quick question, would you happen to know if i’m out side of my local network via Blynk app, will i need to port forward to access my local server? thought i’d ask now before going down the rabbit hole.

Thanks for the help again

Yes, definitely. I also use a DNS redirection service like NoIP.com to make the transitioning of the App from Local WiFi to Cellular a seamless process by using the DNS address in the App setting, instead of the Server IP… which will ONLY work when connected to WiFi.

And yes, that is a 9443 not a 3443… Blynk has this issue with poorly scaled fonts on skinny aspect ratio phones :stuck_out_tongue:

1 Like

Really? I never knew that! :rofl::rofl::rofl:

Pete.

2 Likes

Just for anyone following along trying to set up a local server with USB connection to a raspberry pi, a quick recap on what i have done to get it running (app works when connected to local network… next mission is to gain access from outside).

Basically as per the instructions:
Install java 8
install Socat
After installing Socat i had to run chmod 777 socat if i didn’t the Blynk script wouldn’t run.
install Blynk local server/arduino libraries

After everything was installed i booted up my local server using the following (taken from DOCs):
java -jar server-0.41.0-java8.jar -dataFolder /home/pi/Blynk
next you need to run the USB script so change directory until you’re in the Bylnk script folder located in your Arduino libraries folder.
to run this use the code as per the docs:
./blynk-ser.sh -s UR_IP -p 9443 putting in the IP of your local server

Now when i ran this it would continue to exit/ not establish a connection so in ./blynk-ser.sh i had to make the following change to the following line:
SRVR_CERT=&quot;$SCRIPTPATH/certs/server.crt&quot; replacing with SRVR_CERT=&quot;$SCRIPTPATH/certs/fullchain.crt&quot;

so at this point everything is working while contained to my local network i will update once i have it working from out side… trying to find a work around instead of port forwarding.

also something extra for those using Blynk on EDUROAM network, this link is a quick guide to connecting to it:
https://normally.online/2017/07/11/how-to-connect-your-raspberry-pi-to-eduroam/

also thank you again @Gunner

1 Like