FarmBot / Farmbot-Web-App

Setup, customize, and control FarmBot from any device
https://my.farm.bot
MIT License
900 stars 335 forks source link

Installation Failure #674

Closed Darchevil closed 6 years ago

Darchevil commented 6 years ago

Expected Behavior

Rails mqtt:start started correctly

Actual Behavior

Start failed

Starting broker... Starting JWT Auth app. Trying to fetch public key from: http://127.0.0.1:5672/api/public_key

BOOT FAILED

Error description: {could_not_start,rabbit_auth_backend_jwt, {{shutdown, {failed_to_start_child,rabbit_auth_backend_jwt_pub_key_fetcher, {error,socket_closed_remotely}}}, {rabbit_auth_backend_jwt_app,start,[normal,[]]}}}

Log files (may contain more information): /var/log/rabbitmq/rabbit@b959bd50efb6.log /var/log/rabbitmq/rabbit@b959bd50efb6-sasl.log

{"init terminating in do_boot",{could_not_start,rabbit_auth_backend_jwt,{{shutdown,{failed_to_start_child,rabbit_auth_backend_jwt_pub_key_fetcher,{error,socket_closed_remotely}}},{rabbit_auth_backend_jwt_app,start,[normal,[]]}}}} init terminating in do_boot ()

Steps to Reproduce

RickCarlino commented 6 years ago

@Darchevil It looks like you may have started the MQTT server before running rails api:start. The MQTT server will not boot if the web app is not ready to accept connections.

Another possibility is that you started the servers in the correct order (Web API -> MQTT) but the Web server was not yet ready.

You will know the webserver is fully loaded when you see a message like this:

08:46:42 rails.1   | Listening on 0.0.0.0:3000, CTRL+C to stop

Another way to make sure the server is running properly is to open http://127.0.0.1:5672/api/public_key in a browser before launching the MQTT server. You should see something similar to this:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtO3WNKpGAQ9NjfNGbONY
C+pYTVfAoHNnvs6F0ve7NlNL/jAJ3/uPHdGMVPWLWxM6IpVLoz4vcOYpioQVtAZx
XH1aoFZD24CdhlzPR5XpCkI3lsXplqzQDsIToIG4kY0UuF8F439DEjvu5g+1laBD
u7ikad7P5QyQBr6v8Ph25qR9GGhdFV3VlSl/HUER8r5SWpSQbXdsFEh/wkMXNxms
Zyb5DlTSNEwW5I6KjegEextyXh6Q/cYnEjp7fe/ElJgAGUdM4Xx3+qorCdMQ0FZJ
31IDi9c3Jd+5Rl4FIpVX/7Ch1HhFq3krKJFWAyHVU5kJNB0S+56lbj2k+I08P/10
TwIDAQAB
-----END PUBLIC KEY-----

Please let me know if you require further assistance.

Darchevil commented 6 years ago

Hello ! Thanks for your answer !

I deleted the Public key into the file Application.yml. Does it change anything ?

I still can't launch the api:start. This is the redundant message : 21:00:59 logger.1 | lib/log_service.rb:9: warning: already initialized constant Bunny::TCPConnectionFailedForAllHosts 21:00:59 logger.1 | lib/log_service.rb:9: warning: previous definition of TCPConnectionFailedForAllHosts was here 21:00:59 logger.1 | MQTT Broker is unreachable. Waiting 5 seconds... 21:01:04 logger.1 | W, [2018-02-25T21:01:04.250000 #7115] WARN -- #<Bunny::Session:0x4d1ecb0 guest@localhost:5672, vhost=/, addresses=[localhost:5672]>: Could not establish TCP connection to localhost:5672: Connection refused - connect(2) for 127.0.0.1:5672 21:01:04 logger.1 | lib/log_service.rb:9: warning: already initialized constant Bunny::TCPConnectionFailedForAllHosts 21:01:04 logger.1 | lib/log_service.rb:9: warning: previous definition of TCPConnectionFailedForAllHosts was here 21:01:04 logger.1 | MQTT Broker is unreachable. Waiting 5 seconds...

And when i want to open http://127.0.0.1:5672/api/public_key in a browser, i can't reach the server and i did not launched the mqtt server yet.

Darchevil commented 6 years ago

Hello again !

After my reset, i tried to run the RAILS_ENV=test... I have this result :

Finished in 3.95 seconds (files took 8.34 seconds to load) 42 examples, 10 failures

Failed examples:

rspec ./spec/mutations/sequences/create_spec.rb:38 # Sequences::Create Gives validation errors for malformed sequence_id rspec ./spec/mutations/sequences/create_spec.rb:29 # Sequences::Create Gives validation errors for malformed pin_mode rspec ./spec/mutations/sequences/create_spec.rb:15 # Sequences::Create Builds a sequence rspec ./spec/mutations/sequences/create_spec.rb:21 # Sequences::Create Gives validation errors for malformed AST nodes rspec ./spec/mutations/sequences/create_spec.rb:54 # Sequences::Create Gives validation errors for malformed OP rspec ./spec/mutations/sequences/create_spec.rb:46 # Sequences::Create Gives validation errors for malformed LHS rspec ./spec/mutations/points/update_spec.rb:5 # Points::Update prevents remove of tool from actively used tool slots rspec ./spec/controllers/api/tools/create_spec.rb:19 # Api::ToolsController#create creates a new (detached) tool rspec ./spec/controllers/api/tools/create_spec.rb:41 # Api::ToolsController#create creates a tool with an valid pullout direction rspec ./spec/controllers/api/tools/create_spec.rb:9 # Api::ToolsController#create creates a new tool

Randomized with seed 20305

Coverage report generated for RSpec to /home/darchevil/FWA/Farmbot-Web-App/coverage. 1819 / 2306 LOC (78.88%) covered. {"meta": {"status": 400}, "error": {"reason": "Please provide the repository token to upload reports via -t :repository-token", "context": null}}

I hope I detailed the issue.

Thanks

RickCarlino commented 6 years ago

I deleted the Public key into the file Application.yml. Does it change anything?

No, it shouldn't matter.

I still can't launch the api:start. This is the redundant message

You're seeing that message because you still need to run rails mqtt:start OR, if the MQTT server is running, there is something preventing MQTT from accepting connections such as:

when i want to open http://127.0.0.1:5672/api/public_key in a browser, i can't reach the server

What do you see? An empty screen or an error?

Darchevil commented 6 years ago

This is my Application.yml file :

# ░██████░░███████░░█████░░░██████░░
# ░██░░░░░░░░██░░░░██░░░██░░██░░░██░  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.
#
#  PLEASE READ ALL ENTRIES.
# =============================================================================
# If your server is on a domain (eg: my-own-farmbot.com), put it here.
# DONT USE `localhost`. USE A REAL IP OR DOMAIN!
API_HOST: "192.168.2.1"
# 3000 for local development. 443 is using SSL. You will need `sudo` to use PORT
# 80 on most systems.
API_PORT: "3000"
# MUST REPLACE.
# Generate a secret by typing `rake secret` into the console.
DEVISE_SECRET: "rake secret"
# FarmBot OS update server. Use default if you don't have a special use case.
# Off grid servers may have issues connecting to our update URL.
OS_UPDATE_SERVER: "default"
# Where is your MQTT server running?
# Use a REAL IP ADDRESS if you are controlling real bots.
# 0.0.0.0 is only OK for software testing. Change this!
MQTT_HOST: "172.17.0.1"
# For email delivery. Who is your email host?
SMTP_HOST: "smtp.gmail.com"
# Optional with default of 587
SMTP_PORT: "587"
# Set this if you don't want to deal with email verification of new users.
# (self hosted users)
NO_EMAILS: "TRUE"
# If you are using a shared RabbitMQ server and need to use a VHost other than
# "/", change this ENV var.
MQTT_VHOST: "/"
-----------------------------------------------------------------------------------------

For the API host i've chosen a random IP address. Same for MQTT host. Should i take my Local address like "127.0.0.1" for API host and MQTT host. Which address should i take ?

When i want to open http://127.0.0.1:5672/api/public_key, there is an error "ERR_INVALID_HTTP_RESPONSE"

Thank you.

RickCarlino commented 6 years ago

my Application.yml file

@Darchevil Are 172.17.0.1 and 192.168.2.1 the actual IP addresses of the machines running MQTT and Web App servers? They must be valid IP addresses that are reachable from your local LAN or the public internet.

Another question: Are you running the MQTT server on a different machine than the web app? If not, MQTT_HOST and API_HOST can use the same IP.

an error "ERR_INVALID_HTTP_RESPONSE"

Was there a reason you chose to use post 5672 in your browser, but use post 3000 in application.yml?

I would recommend port 3000 for now, until the other configuration issues are solved.

If you really do not want to use port 3000, you will need to set API_PORT to 5672 and run the server like this:

PORT=5672 rails api:start

Again, I do not recommend using port 5672 because it complicates the server setup.

Darchevil commented 6 years ago

Hello !

Thanks for your help. It's all working. I just had put bad IP addresses.

See you !

RickCarlino commented 6 years ago

@Darchevil I'm glad you got it working! :+1: