Page 1 of 1

Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 30 September 2017 15:37
by Sjonnie2017
Installed Monit as per instructions in the wiki. But somehow I can not get it to work properly.

Running on a Pi 3 connected to a wired network. Installation is done using default settings.

This is my log:

Code: Select all

[CEST Sep 30 15:14:02] info     : Starting Monit 5.20.0 daemon with http interface at [*]:2812
[CEST Sep 30 15:14:02] info     : Monit start delay set to 300s
[CEST Sep 30 15:19:02] info     : 'RPi3' Monit 5.20.0 started
[CEST Sep 30 15:19:04] error    : 'domoticz' failed protocol test [HTTP] at [127.0.0.1]:8080/json.htm?type=command¶m=getversion [TCP/IP] -- Connection refused
[CEST Sep 30 15:19:46] error    : Denied connection from non-authorized client [127.0.0.1]
[CEST Sep 30 15:19:46] error    : Error receiving data -- Connection reset by peer
These are my settings in the /etc/monit/monitrc (snipped to show only the information regarding Domoticz)

Code: Select all

  set daemon 300            # check services at 2-minute intervals
   with start delay 300     # optional: delay the first check by 4-minutes (by
#                           # default Monit check immediately after Monit start)
(snip)
  set mailserver smtp.gmail.com port 587
  username "[email protected]" password "PASSWORD" (of course changed it to the correct values)
  using tlsv1
  without timeout 30 seconds
  set alert [email protected] (of course changed it to the correct values)
(snip)
  set httpd port 2812 and
      use address 0.0.0.0                     # only accept connection from localhost
      allow 0.0.0.0/0.0.0.0                   # allow localhost to connect to the server and
      allow admin: monit                      # require user 'admin' with password 'monit'
(snip)
  check process domoticz with pidfile /var/run/domoticz.pid
  start program = "/etc/init.d/domoticz.sh start"
  stop  program = "/etc/init.d/domoticz.sh stop"
  if failed
     url http://127.0.0.1:8080/json.htm?type=command&param=getversion
         and content = '"status" : "OK"'
     for 2 cycles
     then restart
  if 5 restarts within 5 cycles then exec "/sbin/reboot"
The web interface shows me "connection failed" for Domoticz.

Any help appreciated! :)

Greetz,

Sjonnie

Edit: These are the contents of the email I get from monit (so notification works ;) )

Code: Select all

Connection failed Service domoticz 

	Date:        Sat, 30 Sep 2017 15:29:06
	Action:      restart
	Host:        RPi3
	Description: failed protocol test [HTTP] at [127.0.0.1]:8080/json.htm?type=command&param=getversion [TCP/IP] -- Connection refused

Your faithful employee,
Monit

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 30 September 2017 16:03
by SweetPants
Is 127.0.0.1 in the list of IP's that can login without username/password Setup->Settings->Local networks?

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 30 September 2017 16:12
by Sjonnie2017
Hi,

Tx for your reply! :)

This is what I have in Local Networks in the settings:
127.0.0.*;192.168.16.*
Thought that would be enough. Is it?

Greetz,

Sjonnie

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 30 September 2017 16:18
by SweetPants
Yes, should be enough. Can you post your monit config file?

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 30 September 2017 16:34
by Sjonnie2017
Hi,

Tx for your continued support!

Is there another file than this one?

/etc/monit/monitrc

Because I showed the relevant contents of that file in my previous post. If you need the full contents I'll be happy to comply (need to anonimize it first though ;) )

If there is another config file please let me know.

Greetz,

Sjonnie

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 30 September 2017 18:32
by SweetPants
For every service i use a separate .conf file in /etc/monit/conf.d

For domoticz i only check the PID like:

check process domoticz with pidfile /var/run/domoticz.pid
start program "/etc/init.d/domoticz.sh start"
stop program "/etc/init.d/domoticz.sh stop"

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Sunday 01 October 2017 7:29
by Sjonnie2017
Hi,

Removed the "if failed ..." condition and now monit is working.

Tx! Much appreciated!

Verstuurd vanaf mijn YOGA Tablet 2-1050F met Tapatalk


Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Friday 10 September 2021 11:36
by rolandtwilt
I have had the same problem as above (connection reset by peer) I did 2 things to fix it:

1. Replace this:

Code: Select all

  check process domoticz with pidfile /var/run/domoticz.pid
  start program = "/etc/init.d/domoticz.sh start"
  stop  program = "/etc/init.d/domoticz.sh stop"
  if failed
     url http://127.0.0.1:8080/json.htm?type=command&param=getversion
         and content = '"status" : "OK"'
     for 2 cycles
     then restart
  if 5 restarts within 5 cycles then exec "/sbin/reboot"
With this:

Code: Select all

check process domoticz with pidfile /var/run/domoticz.pid
start program "/etc/init.d/domoticz.sh start"
stop program "/etc/init.d/domoticz.sh stop"
and
2. this:

Code: Select all

  set httpd port 2812 and
      use address 0.0.0.0                     # only accept connection from localhost
      allow 0.0.0.0/0.0.0.0                   # allow localhost to connect to the server and
      allow admin: monit                      # require user 'admin' with password 'monit'
with:

Code: Select all

  set httpd port 2812 and
      use address <address of pi>                     # only accept connection from localhost
      allow <local network range>/255.255.255.0                   # allow localhost to connect to the server and
      allow admin: monit                      # require user 'admin' with password 'monit'

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Friday 10 September 2021 12:39
by waltervl
rolandtwilt wrote: Friday 10 September 2021 11:36 I have had the same problem as above (connection reset by peer) I did 2 things to fix it:
As described in section webservice of the wiki: https://www.domoticz.com/wiki/Monitoring_domoticz

Re: Monit - Error receiving data -- Connection reset by peer ??

Posted: Saturday 11 September 2021 22:18
by AllesVanZelf
Have you configured Domoticz on port 8080?
Are you running Domoticz in a docker container? In that case use the network ip-address of this server/raspberry. something like 192.168.x.x or 10.x.x.x
instead of 127.0.0.1.