Local Farmbot Software

Hi @RickCarlino
for some reason, nothing is happening if I enter every information and enter the IP adress of my local LAN
web frontend server and press submit configuration…
How I can debug further?

Second question, if I open and log into the local webfrontend, is this what I should see? Without connected bot?

Cheers
Klim

@Klimbim

Ahm, could you please give us some further information about your setup?

(1) what have you done so far?
(2) some information about the server (OS/Hardware) could be useful
(3) are you using nginx/apache in front of nodejs?
(4) do you have any background on that stuff or is it more like trial/error or fire&forget :wink:

Chris

@volkc
thanks very much for your support, I appreciate it!!!
I guess what is really missing for the local installation is an overview of the components (software pieces)
which need to run together. At the moment it was only my brain which detected the software in use
because of the installation commands which are needed… I guess that this would help a lot even for
very experienced software cracks…

(1) What have you done so far:
Server

  • sticked mostly to github and this docu which has some big errors in it:
    http://www.farmbot.wiki/index.php?title=Software_installation
  • installed ruby 2.3.3 and the farmbot packages
  • installed a postgresql DB, created a user
  • edited config/application.yml to what I found most logic and appropriate
  • NO MQTT server installed yet
  • Status: Log in possible via web browser, but then see above
  • running the server currently manually with rails s -b IP

Client

  • downloaded latest FarmBot OS and installed on RP, works fine, the farmbot WiFi opens up
  • after entering connection details for WiFi, username and pw it would not let me enter the IP
    of the local server; if I enter it and try to press β€œsubmit configuration” nothing happens…
  • if I leave the server field empty the raspi tries something but ends up with a reebot

(2) Setup hard/software

  • server running in LAN
  • ubuntu 16.04 running with standard installation

(3) are you using nginx/apache in front of nodejs?

  • not that I know of, I only installed nodejs

(4)
I think I have got basic knowledge but it is definitely try, see error, analyze and then
move on.

I would appreciate if I would know where to look in the logs for the server application as
well as the Raspi application. That would help a lot!

Thanks for your support again, looking forward to getting the thingi running this weekend! :heart_eyes:

Sry, but forget those installation instructions, they’re incomplete and for me they look a little bit hacky. Beside that it would make some sense to document everything in our community wiki :slight_smile:

Do you want to run that stuff on another PI? I will have some time at the weekend and could provide an image with everything installed. How does that sound?

I would appreciate to work on the right way to get it working in order to understand it. I think that I am almost there and it will need only some tweeks here and there.

I wanted to use the time and installed already the software on the Raspi :wink:

So if you could guide me to the solution for the server installation I would appreciate it. I would then edit the server installation instructions for the rest of the farmbot world :wink:

Okay :slight_smile: Could you please post your config files somewhere so i can have a look on them? That would make things way easier!

You mean this file?

Please have a look at my application.yml config file. I only posted the uncommented lines,
as the forum seems to have problems with the # uncomment sign.

Cheers

β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘
β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–ˆβ–ˆβ–‘ READ THIS BEFORE USING IT.
β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘ SEE NOTES BELOW:
β–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘
β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘
You will hit issues if any of these are set to the wrong value.
Please read each line of this file before starting the server.

=============================================================================
API_HOST: β€œ0.0.0.0”
API_PORT: β€œ3000”
DOCS: β€œSet this to any value if you want to generate API docs after running tests”
DATABASE_URL: β€œpostgres://myuser:mypassword@127.0.0.1:5432/farmbot_development”
DEVISE_SECRET: β€œUsed for devise. Use rake secret to generate a new value.”
FW_UPDATE_SERVER: β€œhttps://api.github.com/repos/FarmBot/farmbot-arduino-firmware/releases/latest”
OS_UPDATE_SERVER: β€œhttps://api.github.com/repos/farmbot/farmbot_os/releases/latest”
HEROKU_SLUG_COMMIT: β€œThis is set by Herok, used by Frontend to show current version.”
MQTT_HOST: β€œ0.0.0.0”
NPM_ADDON: β€œUsed by FarmBot, Inc. to load proprietary extras, like Rollbar.”
SMTP_HOST: β€œsmtp.sendgrid.net”
SMTP_PORT: 587

Hey @Klimbim,

sorry for the delay!

Please replace 0.0.0.0 with the IP address of your server. Furthermore you’ll have to install the mqtt broker and the web api on the same host.

Chris

@volkc: thanks, that was exactly the point. I did not change the API IP from 0.0.0.0 :wink: THANKS!

@RickCarlino,

the only problem I am currently facing with firefox and chrome:

Of course all values are entered as they should be.

Any idea? :eyes:

@Klimbim I think you’re missing the http:// and :3000 part. Glad to hear you got it setup fine! :slight_smile:

Actually- I should not assume that you are running on port 3000, sorry! Be sure to right the URL as http://192.168.0.38:XYZ where XYZ is the server’s port number. On my local machine, it is port 300.

@RickCarlino
Fine is exxagerated, I am about to get it running on a very fragile setup :slight_smile:

So I tried and it seem that the raspi connects to my WiFi, because I see a client with nerves-2644 connected assuming that this is the client because the bot sets up the farmbot-2644 net…? Buuuut it does not connect to the server and reboots after some time and establishes its own config wifi again…

Is there any possibility to debug (view logfiles) on the raspi in order to see what he did not like?

@Klimbim @RickCarlino I’m trying to do a local install, got the mqtt gateway and Web API running on the same machine and they are talking togehter (which means API_HOST, API_PORT as well as MQTT_HOST are all set accordingly to a real IP and the used port number). I can also log into the WebApp and see in MQTT.fx when I try to send controls.
The one (and unfortunately most important) thing I can’t get to work is the local connection from the Farmbot to the WebApp/API. I used the credentials that i also use to login to the WebApp and for the Server URL I use http://<local IP mentioned before>:3000 and I can see something happening in the Farmbot terminal (namely FarmEvent Load three times) but the FarmBot won’t show up in the WebApp as connected.
farmbot_webapp_no_conn

I initially tried the setup via https://my.farmbot.io which worked flawlessly, then I factory-reset the Farmbot and even reflashed the image but I can’t get the local setup to work.

Any help is appreciated, thanks in advance

@grubFX a few questions:

  • Are you loading the web app from the same machine that runs that server?
  • Have you been able to open the web app from a machine other than the one that runs the server?
  • What do you see when you run git log -n 3? Please copy/paste it.
  • When you ran configurator, did you enter the info like this:

image

…but not like this?

image

Rails might not be binding to the correct network interfaces or only allowing connections from localhost, which means your browser can connect OK, but outside devices (like FarmBot) cannot.

I’m loading the web app from another client, since the server is just a headless Ubuntu installation and I can enter from this other machine (Chrome and Firefox).

For the configurator I entered the real IP (tried, again, both Chrome and Firefox, but it didn’t connect anyways).

Output from git log -n 3:

$ git log -n 3
commit 767648768aa069b2faff4cb200187babf172606c
Merge: 5476432a 3e13b705
Author: Rick Carlino <RickCarlino@users.noreply.github.com>
Date:   Tue Sep 19 05:41:15 2017 -0500

    Merge pull request #458 from gabrielburnworth/master

    Farm Designer Map multiple plant selection and deletion UI

commit 3e13b70576cbdddcf9106b1b1e29b52156430323
Author: gabrielburnworth <gabrielburnworth@users.noreply.github.com>
Date:   Tue Sep 19 00:28:38 2017 -0700

    simplify add plant props

commit a77e96c6bfe163922b243140a23d9bd0496654ec
Author: gabrielburnworth <gabrielburnworth@users.noreply.github.com>
Date:   Tue Sep 19 00:12:11 2017 -0700

    multiple plant selection and deletion ui
$

(How) can I force rails to listen on all interfaces/accept requests from all IPs?
I even cleared any iptables rules and disabled ufw, just to be sure and cause it’s only the internal network and the server is there for the sole pupose of running the WebApp and mqtt gateway.

One more, just to clarify: I start the Farmbot-Web-App with npm run dev and after that (always using another ssh session in another window) I start the mqtt gateway with WEB_API_URL=http://<Ubuntu server IP>:3000 npm start each from their respective folders that I cloned from Github. Right?

Let’s try this instead of npm run dev, just for the sake of debuging:

# Window 1:
rails s -p 3000 -b 0.0.0.0
# Window 2:
./node_modules/.bin/webpack-dev-server --config config/webpack.config.js
# Window 3:
rake jobs:work

The -b 0.0.0.0 will force Rails to listen to all interfaces, but strangely, Procfile.dev is already set up to do that :thinking:, leading me to believe it is a different issue.

Is it safe for me to assume all three machines (server, client, bot) are within the same LAN? Sometimes firewalls can get in the way- are there any external firewalls in place outside of ufw?

That is correct.

One last question:

  • Have you seen messages from the bot on MQTTfx at all? Or just messages from the browser? You should see them on channel bot/BOT_NAME/from_device. If you have never seen a /from_device message, it is probably just a wifi strength / connectivity issue. Temporarily hooking up to ethernet might be a good way to test this theory.

Window 1:

$ ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js
Project is running at http://0.0.0.0:3808/
webpack output is served from //localhost:3808/webpack/
ts-loader: Using typescript@2.5.2 and /home/grubfx/git/Farmbot-Web-App/tsconfig.json
Hash: 03dfab3d86bf451eaf1d
Version: webpack 3.5.5
Time: 33124ms
                               Asset     Size  Chunks                    Chunk Names
21641a11858547e863d132ca9bf4f7a4.eot  80.5 kB          [emitted]
05b51a6b50b3ea1fe0c380207f164a53.eot  82.4 kB          [emitted]
                           bundle.js  6.31 MB       0  [emitted]  [big]  bundle
                       front_page.js  4.36 MB       1  [emitted]  [big]  front_page
                   password_reset.js  4.34 MB       2  [emitted]  [big]  password_reset
                       tos_update.js  3.04 MB       3  [emitted]  [big]  tos_update
                     verification.js   2.1 MB       4  [emitted]  [big]  verification
                       manifest.json  0 bytes          [emitted]
  [10] ./node_modules/i18next/dist/es/index.js 890 bytes {0} {1} {2} {3} {4} [built]
  [26] ./webpack/util.ts 13.9 kB {0} {1} {2} {3} {4} [built]
 [238] (webpack)-dev-server/client?http://0.0.0.0:3808 5.83 kB {0} {1} {2} {3} {4} [built]
 [985] multi (webpack)-dev-server/client?http://0.0.0.0:3808 ./webpack/entry.tsx 40 bytes {0} [built]
 [986] ./webpack/entry.tsx 644 bytes {0} [built]
 [987] ./webpack/routes.tsx 14.3 kB {0} [built]
[1332] multi (webpack)-dev-server/client?http://0.0.0.0:3808 ./webpack/front_page/index.tsx 40 bytes {1} [built]
[1333] ./webpack/front_page/index.tsx 432 bytes {1} [built]
[1334] ./webpack/front_page/front_page.tsx 13.6 kB {1} [built]
[1338] multi (webpack)-dev-server/client?http://0.0.0.0:3808 ./webpack/verification.ts 40 bytes {4} [built]
[1339] ./webpack/verification.ts 4.04 kB {4} [built]
[1340] multi (webpack)-dev-server/client?http://0.0.0.0:3808 ./webpack/password_reset/index.tsx 40 bytes {2} [built]
[1341] ./webpack/password_reset/index.tsx 845 bytes {2} [built]
[1343] multi (webpack)-dev-server/client?http://0.0.0.0:3808 ./webpack/tos_update/index.tsx 40 bytes {3} [built]
[1344] ./webpack/tos_update/index.tsx 9.09 kB {3} [built]
    + 1330 hidden modules
webpack: Compiled successfully.

Window 2:

$ rails s -p 3000 -b 0.0.0.0
WARNING: Use strings for Figaro configuration. true was converted to "true".
=> Booting Thin
=> Rails 5.1.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
W, [2017-09-21T16:41:20.325744 #5995]  WARN -- : [SKYLIGHT] [1.3.1] Running Skylight in development mode. No data will be reported until you deploy your app.
(To disable this message for all local apps, run `skylight disable_dev_warning`.)
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop

…and tons of output as soon as I log into the WebApp


Window 3:

$ rake jobs:work
WARNING: Use strings for Figaro configuration. true was converted to "true".
W, [2017-09-21T16:31:37.993886 #5756]  WARN -- : [SKYLIGHT] [1.3.1] Running Skylight in development mode. No data will be reported until you deploy your app.
(To disable this message for all local apps, run `skylight disable_dev_warning`.)
[Worker(host:<my_hostname> pid:5756)] Starting job worker
2017-09-21T16:31:38+0200: [Worker(host:<my_hostname> pid:5756)] Starting job worker

All devices are in the same LAN with no firewalls between them, all on the same switched network.

I performed a factory reset and connected the FarmBot via Ethernet now (ping is now <1ms, was ~4ms on WiFi before, so most definitely using Ethernet now), but I haven’t seen any messages from_devices yet (also not on WiFi before).

Here are a few things that may help:

Check that your application.yml has something similar to the following:

MQTT_HOST: "192.168.1.100"
API_HOST: "192.168.1.100"
PORT: "3000"

And you are running:
/mqtt-gateway$ WEB_API_URL=http://192.168.1.100:3000 npm start
/Farmbot-Web-App$ npm run dev

(Since you are running MQTT on the same server, you could probably just run npm start in /mqtt-gateway and npm run dev in /Farmbot-Web-App, but either approach should work.)

For SERVER during FarmBot OS configuration: http://192.168.1.100:3000.

After you have completed FarmBot OS configuration, if you restart MQTT at any point, you will need to power cycle your device to reconnect it to the app. When you do, do you see something like this in the terminal for the app?
Started POST "/api/tokens" for . . . (there’s a long string in the request, so it should be easy to spot)

If you don’t, the device isn’t connecting to the app, and will not connect to MQTT either. You should also see that POST after pressing SUBMIT during FarmBot OS configuration.

Good to know that a power cycle is necessary, I might not have been doing this every single time, but i will from now on.

Concerning the POST /api/tokens:

22:24:11 rails.1   | Started POST "/api/tokens" for <IP of the FarmBot> at 2017-09-21 22:24:11 +0200
22:24:11 rails.1   | Processing by Api::TokensController#create as JSON
22:24:11 rails.1   |   Parameters: {"user"=>{"credentials"=>"< super long string ending with == >"}, "token"=>{"user"=>{"credentials"=>"< another long string ending with == >"}}}
22:24:11 rails.1   |   User Load (0.4ms)  SELECT  "users".* FROM "users" WHERE "users"."email" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["email", "bla@bla.com"], ["LIMIT", 1]]
22:24:11 rails.1   |   Device Load (0.2ms)  SELECT  "devices".* FROM "devices" WHERE "devices"."id" = $1 LIMIT $2  [["id", 20], ["LIMIT", 1]]
22:24:11 rails.1   | [active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (0.76ms)
22:24:11 rails.1   | Completed 200 OK in 84ms (Views: 3.9ms | ActiveRecord: 0.6ms)

I got this after I power cycle the FarmBot but not if I submit a new configuration, might the issue be therefore based around the configurator somewhere?