Running Server on Local Raspberry PI Network

Hello!

I would like to set up the toolbox to run on a Raspberry Pi that is set up as a hotspot, without connecting through a local router (i.e. I can connect the RPi’s wifi network on my iphone, and can see objects on the edge-server). I have Toolbox running on a Pi 3B+ and can see the web interface when connected to its wifi network, but the toolbox app can’t find any servers when connected to its network (tried specifying the ip address and port in the developer tab on the app). Everything works perfectly well if the RPi is plugged into my router with an ethernet and my phone is connected to the router (using a hardware interface that talks over USB serial), but I get the error “Your not on a network. Can’t send anything” if the ethernet is not plugged in. Is there any way I can set up the toolbox to run locally and connect to my phone on its network without going through a router?

Thanks!
Matt

Hi @MattMueller its not fully clear to me what setup you use. It sounds like you are connecting your iPhone via a USB Ethernet adapter to the network. Is that right? If thats the case, the toolbox will not work. You need to use the Wireless adapter.

If you have problems with the Server, check if the server web interface shows multiple network adapter. If that is the case chose the one that is connected to your router and restart the server.

Hi @valentin. Sorry, not the most clear. Let me try again.

I have the toolbox installed and working on a Raspberry Pi (works with a serial hardware interface plugged into the pi). I then went through this guide for setting up my RPi as a “hotspot” (a routed access point), so it casts a wifi network (I called the SSID “PiToolbox”) but is plugged into my home network router with an ethernet cable.

In toolbox’s web interface, I then see “ETH” and “WLAN” options. If I select ETH and have my phone connected to my home wifi network, everything works. If I select “WLAN” and have my phone connected to the “PiToolbox” wifi network, it doesn’t find any objects.

The use case is that I want to send just a raspberry pi to a school, tell them to plug in their USB device, download the toolbox app on their phone and connect to the “PiToolbox” wifi network, and be ready to use Spatial Toolbox with this hardware interface. No need to connect to the internet or have any other local network. Is that possible to set up?

Thanks,
Matt

Ahh I get it. I had this problem in the past as well. It has to do with the network routing inside the PI. The same problem will apply to any nodejs server / access point / PI situation.

I could find some info on that with a quick search:

Please let me know if this helps and what your solution is. If it does not help we can dig deeper.

Thanks! I’m testing the limits of my networking knowledge here, so please bear with me :slight_smile:.

I realized a first silly mistake I was making - I was using port 52316 for the discovery server in my toolbox app instead of port 8080. Now when I am connected to the “PiToolbox” wifi network on my phone, I am able to see objects, as long as the ethernet is plugged into the Pi. If the ethernet is not plugged into the Pi, as soon as I turn on the discovery server toggle in the developer tab of the toolbox app, I get the following error message and then the server stops.

2021-02-17T20:24:44.442Z - debug: “Your not on a network. Can’t send anything”
/home/pi/vuforia-spatial-edge-server/server.js:1186
if (err) throw err;
^
Error: send ENETUNREACH 255.255.255.255:52316
at doSend (dgram.js:692:16)
at defaultTriggerAsyncIdScope (internal/async_hooks.js:430:12)
at afterDns (dgram.js:638:5)
at processTicksAndRejections (internal/process/task_queues.js:81:21) {
errno: -101,
code: ‘ENETUNREACH’,
syscall: ‘send’,
address: ‘255.255.255.255’,
port: 52316
}

Is there any way of disabling this UDP network part of the server and just have it work on the localhost network with port 8080? If not, would my goal be to set up an iptable rule on the Raspberry Pi to forward the UDP network (port 52316) to port 8080? Or am I off the mark entirely?

Thanks!
Matt

You should not use the discovery server method in a local network. Usually the UDP discovery service will automate everything in the background. We added the discovery server method for networks where UDP is blocked. However that comes with the burden to manually enter the server IP, which is otherwise automated.

You need to make sure that the server can send and receive UDP and TCP/IP via your network.

Hi @valentin. I struck out with trying to use the iptables method to allow the networking, but @ptc-pz figured out a way to get it to work. Following the tutorial linked here, and using DNSmasq Config 2 - Internet Routed (this allows you to install the toolbox from the internet if you have an ethernet connected to the Pi). The one extra step to have it work once the ethernet connection to the web is removed is to add the following line to the end of your “dnsmasq.conf” file, where the ip address is your pi’s static ip on the hotspot.

address=/#/192.168.50.10

Hi @valentin – I’m working with Matt on this project, and the next step we want to implement is to start the server from a browser. We’re using php to call ‘node /home/pi/vuforia-spatial-edge-server/server.js’. This works, but it seems that perhaps because Server.js is being called from /var/www/html, it throws the error below— any ideas on how we can address this?

=> 2021-02-24T16:42:12.277Z - [34mdebug[39m: [32m'**** DIR: '[39m '/var/www/vst-edge-server' 
=> 2021-02-24T16:42:12.297Z - [34mdebug[39m: [32m'Something went wrong with initSync'[39m

You need to give read write access to that folder or change some code on the server for where to find the toolbox content folder structure.

You will find all the spots searching for „vst-edge-server“.

If you find an elegant solution that can work for your use case and still honors the server default functionality, send a pull request.

Hi @MattMueller,

I am currently trying to realise up a similar use case like yours. The goal is, to connect everything to the RPi’s access point and use the spatial edge server <–> spatial toolbox combination without any internet connection.

Just to make things clear, because I am not sure if I got you right: the WiFi builds up by the RPi also have an internet connection? Because in the guides it is also explained how to route the Pi’s network and I am not sure if you skip those steps or not.

MattMueller 9d
No need to connect to the internet or have any other local network. Is that possible to set up?

Regarding your second post you skip those steps…

Because this is my main problem, I can not even start the spatial toolbox app when my Client is connected to the RPi’s WiFi (without internet/ routing anything).

An this weekend I will try your referred way to setup the access point, perhaps this helps…

Thanks for any ideas!

Hi @lde,

Very cool! Yes we had been running into the same issue when unplugging the eth0 connection to the internet. We set it up with routing initially to be able to download everything we needed from the internet and access wifi hardware interfaces. When we wanted to run it entirely off of the RPi hotspot with no eth0 connection, the one step to make it work was to add the following line to the end of your dnsmasq.conf file (path should be “/etc/dnsmasq.conf”).

address=/#/192.168.50.10

This will route all internet traffic back to the local network, so you will need to remove that if you want to re-connect the eth0 network, but that should allow you to connect to any hardware interface connected to the local network. Here is a link to a rough guide on what we’ve tried so far (you’ll see some other stuff that was tried which you can ignore). Would love to hear a little bit about what you’re trying to do if you’re willing to share!

Best,
Matt

Hi @MattMueller,

thank you for your answer. The GitHub repo looks very useful for supporting me tinkering this weekend.

Sorry for asking again but am not quite sure of we are facing the same problem: your problem was, that you don’t found any server nor objects with the spatial toolbox iOS app when connecting to the RPi’s hotspot without any routing to the internet, correct? My problem is, that the spatial toolbox app freezes while loading and won’t even start when I am connected to a network without internet connection.

I am currently running DietPi on my RPi, so I am not sure if the dnsmasq.conf is used. The file exists but it only contains one line.
DietPi uses hostapd for creating the access point but the installation process is automated and optimised, so I am not quite sure if the same config files were used. Perhaps DietPi is something interesting for your no-coding-required paradigm. It is basically an ultra lightweight Debain image which can be configured through an .txt document before the initial boot and will everything set up by its own. dietpi.txt - config file

The plan is to code an MQTT addon for the spatial edge server and communicate with the ESP32 boards and sensors which are connected to the local RPi hotspot. …perhaps a Node-Red integration/ custom node for Node-Red, so that’s potentially possible to connect Home Assistant with the spatial edge server… wee will see how far things go :slight_smile:

Hi @lde,

Very cool idea! I think there’s a lot of potential for using the toolbox in smart home setups (the Hue lights hardware interface is lots of fun to play with).

I think there may be two separate issues here. First, I’ve not used DietPi, but I’d guess the ultra-lightweight debian image does not have a desktop kind of file structure, which is required for the Toolbox’s current setup (the default file structure creates a folder called “spatialToolbox” in the Documents folder that stores all information about your objects). So if you want to use the DietPi, you’ll need to make sure it can work with the Toolbox’s structure.

Second is how the toolbox’s server sends/receives data. As of now, I think the UDP port looks for an external network for connections, so having the node server run on the same device that is hosting the hotspot is a bit of an issue. Our setup also uses hostapd for creating the access point, and uses the dnsmasq to configure the network traffic and routing, then the “address=/#/192.168.50.10” line redirects all traffic back to the Raspberry Pi’s local network, which is setup with hostapd.

I’m certainly not an expert and could be wrong about some of these points, but hope that helps!

Best,
Matt

Hi @MattMueller,

you are partly right, the file structure is different to the standard Raspberry Pi OS. But I am sure that the server and hotspot is running correctly since I can connect to the spatial edge servers web UI. There is also a first prototype of the MQTT addon which is recognised by the server and controllable through the web UI (click on/ off switch in the “Manage Hardware Interfaces” tab and see something in the spatial edge server log).

Fortunately everything is working now without changing everything actually. It turns out, that the spatial toolbox app was not froze, it just needs ~15 sec. for starting up instead of ~3/4 sec. (when connected to a network with proper internet connection). The second problem is, every third or fourth attempt to start the app is without any success, and it keeps stucking on the load screen.

The only thing I did was connecting the Pi to my home network via WiFi an then turn back on the hotspot.

I think, I will set up everything again from scratch the same way using DietPi for testing purpose and give a feedback.

The toolbox and edge server requires NO internet connection.
The slowness for loading the toolbox must be related with the target size that you load from the server in your network.

I assume that the data rate for your network goes down by a lot once you start your PI configuration.

I would suggest running a LAN network quality test with both of your configurations or reducing the target size.