Skip to content
Permalink
Browse files

Update AMQP options to disable heartbeat timeout

This caused errors related to network latency for some users
  • Loading branch information...
ConnorRigby committed Apr 12, 2019
1 parent fbee9ca commit a2ed4fd7b206cb9371528906d58b3285f4f105ea
Showing with 14 additions and 1 deletion.
  1. +2 −0 CHANGELOG.md
  2. +2 −1 VERSION
  3. +10 −0 lib/farmbot/bot_state/transport/amqp/amqp.ex
@@ -1,4 +1,6 @@
# Changelog
# 7.0.3
* Update to AMQP to disable `heartbeat` timeouts

# 7.0.2
* AMQP now reconnects immediately after an unexpected disconnect
@@ -1 +1,2 @@
7.0.2
7.0.3

@@ -194,6 +194,12 @@ defmodule Farmbot.BotState.Transport.AMQP do
{:noreply, [], state}
end

def handle_info({:EXIT, _pid, error}, state) do
Logger.debug 3, "AMQP disconnect: #{inspect(error)}"
send self(), :connect
{:noreply, [], %{state | conn: nil, chan: nil}}
end

@doc false
def handle_celery_script(payload, _state) do
case AST.decode(payload) do
@@ -361,6 +367,10 @@ defmodule Farmbot.BotState.Transport.AMQP do
],
host: mqtt_server,
username: bot,
# This should be set to 0 to disable timeouts.
# RMQ uses tcp-keepalive
# https://github.com/rabbitmq/rabbitmq-erlang-client/blob/0ec41c554dc0e76a605423b0391b6ea0e7df9df4/src/amqp_connection.erl#L120
heartbeat: 0,
password: token,
virtual_host: vhost]

0 comments on commit a2ed4fd

Please sign in to comment.
You can’t perform that action at this time.