linuxserver / docker-domoticz

GNU General Public License v3.0
43 stars 27 forks source link

Domoticz restarts after updating sensor value via JSON API #33

Closed charger closed 5 years ago

charger commented 5 years ago

Host OS: Synology x86_64 GNU/Linux synology_braswell_716+II also Ubuntu 16.04 LTS

docker run -d -p 8080:8080 --name=domoticz -v /tmp/conf:/config -v /etc/localtime:/etc/localtime:ro linuxserver/domoticz:139

/tmp/conf - is empty directory

Step to reproduce:

  1. Create dummy sensor 1.1 In Domoticz "Setup -> Hardware" 1.2 Name: dummy 1.3 Type: Dummy (Does nothing, use for virtual switches only) 1.4 Press "Add" 1.5 Press "Create virtual sensors" 1.6 Name: any 1.7 Sensor Type: Percentage 1.8 Press "Ok"
  2. Update sensor value via JSON API:
    curl -v "http://127.0.0.1:8080/json.htm?type=command&param=udevice&idx=1&nvalue=0&svalue=5"

    Actual result

  3. curl returns:
    > GET /json.htm?type=command&param=udevice&idx=1&nvalue=0&svalue=5 HTTP/1.1
    > Host: 127.0.0.1:8080
    > User-Agent: curl/7.47.0
    > Accept: */*
    > 
    * Empty reply from server
    * Connection #0 to host 127.0.0.1 left intact
    curl: (52) Empty reply from server
  4. Sensor value updates
  5. Domoticz restarts, I thik so because in his log (Setup -> Log) added next lines (each time when I execute curl request):
    2019-01-13 15:02:34.779 Active notification Subsystems: gcm, http (2/13)
    2019-01-13 15:02:34.782 Starting shared server on: :::6144
    2019-01-13 15:02:34.737 Status: Domoticz V4.10343 (c)2012-2019 GizMoCuz
    2019-01-13 15:02:34.737 Status: Build Hash: 3e3f545e, Date: 2019-01-11 09:41:48
    2019-01-13 15:02:34.737 Status: Startup Path: /var/lib/domoticz/
    2019-01-13 15:02:34.777 Status: PluginSystem: Started, Python version '3.6.5'.
    2019-01-13 15:02:34.779 Status: WebServer(HTTP) started on address: :: with port 8080
    2019-01-13 15:02:34.781 Status: WebServer(SSL) started on address: :: with port 1443
    2019-01-13 15:02:34.781 Status: Proxymanager started.
    2019-01-13 15:02:34.782 Status: TCPServer: shared server started...
    2019-01-13 15:02:34.782 Status: RxQueue: queue worker started...
    2019-01-13 15:02:36.785 Status: EventSystem: reset all events...
    2019-01-13 15:02:36.785 Status: EventSystem: reset all device statuses...
    2019-01-13 15:02:36.805 Status: Python EventSystem: Initalizing event module.
    2019-01-13 15:02:36.805 Status: EventSystem: Started
    2019-01-13 15:02:36.805 Status: EventSystem: Queue thread started...
    2019-01-13 15:02:37.244 Status: PluginSystem: Entering work loop.

    docker logs domoticz returns the same information.

Expected result:

  1. Curl should returns body:
    {
    "status" : "OK",
    "title" : "Update Device"
    }
  2. Domoticz shouldn't restart his work loop.

I think this is not a problem with Domoticz itself because:

  1. when I installing Domoticz on RaspberryPi and make curl request it returns body and domoticz didn't restarts.
  2. when I installing Domoticz on my Synology NAS as packet it also works (no restarts after curl request and I get not empty body in response)
  3. when I run container cgatay/domoticz:4.10353-beta-deb it also works (but it doesn't have https). BTW I used:
    docker run -d -p 8080:8080 --name=domoticz_cgatay -v /tmp/cgatay_conf:/config -v /etc/localtime:/etc/localtime:ro cgatay/domoticz:4.10353-beta-deb
tobbenb commented 5 years ago

Have tested it here and sometimes it works and sometimes it restarts Domoticz. Since Domotics is restarting, it's most likely some bug in Domoticz. That doesn't mean it's not related to something in this container. This container is based on Alpine Linux which is not using glibc, but musl. Might be something there making Domoticz crash. I think it's better to ask the Domoticz developers why Domoticz is crashing, as I have no clue what it could be.

charger commented 5 years ago

I have already reported about this problem on Domoticz forum https://www.domoticz.com/forum/viewtopic.php?f=6&t=25818&p=203423#p203423 but without result. So you are my last hope to solve this problem.

tobbenb commented 5 years ago

Reading through that thread I see that you are not the only one with this issue. There was one guy that tried many different containers and had the same problem. So this is a Domoticz issue as far as I see it. One guy even said that if the response takes too long, Domoticz restart. Might be better to add an issue on domticz github page. At least the developers sees it then.

charger commented 5 years ago

I'll post issue on Domoticz git hub. But take a look at cgatay/domoticz:4.10353-beta-deb, it also based on Alpine Linux but works fine. Is it possible to track down differences between the images?

Freekers commented 5 years ago

I have exactly the same issue since switching to the Docker image. Previously I was using the Domoticz Synology Package by Jumbotroll which did not have this issue. Therefore I'm not sure if this bug is caused just by Domoticz itself or a combination of factors/dependencies.

charger commented 5 years ago

You are right, this is combination of factors, but probably Domoticz can provide some logs, about why it restarts his event loop. I created issue in Domoticz GitHub, but no response yet.

Freekers commented 5 years ago

One big difference between the Docker image of 'cgatay' and linuxserver.io, is that cgatay is almost 6 months ahead of linuxserver.io's master branch. So perhaps it was indeed a Domoticz issue in the past, but has been fixed in one of the future beta versions.

sparklyballs commented 5 years ago

@Freekers , the :latest (default tag) of this image is using the very latest beta version.

2019-01-21 15:49:22.388 Status: Build Hash: 060accf8, Date: 2019-01-18 15:46:09

BIG difference between a 3 day old build and something that is 6 months behind something, incidentally that would make cgatay's version practically 6 months in the future... neat trick which if stephen hawking were still around would be very interested in.....

Freekers commented 5 years ago

I'm not following your logic regarding the past/future/Stephan Hawking thing, but you are right regarding the master branch being the very latest beta version. Thanks for pointing it out.

tobbenb commented 5 years ago

@charger Have you tested this with the latest version or just the 139 tag?

charger commented 5 years ago

linuxserver/domoticz:latest Domoticz v4.10362 Build Hash: 060accf8 Build Date: 2019-01-18 17:46:09' Problem reproduces.

cgatay/domoticz:4.10353-beta-deb Domoticz v4.10353 Build Hash: 0fa125f6 Build Date: 2019-01-13 00:12:34' Problem doesn't reproduce.

Actually, the big difference between images is not a Domoticz version, it is the base image. lsiobase/alpine:3.7 linuxserver Dockerfile vs debian:stretch cgatay Dockerfile I was wrong when said that cgatay/domoticz:4.10353-beta-deb based on Alpine linux. Alpine linux used in cgatay/domoticz:4.10353-beta Dockerfile and this image has the error.

tobbenb commented 5 years ago

Then it's musl related. It's something domoticz have to fix, unless it's a bug in alpine or one package we install. Hopefully the domoticz developers can see why it's restarting.

idekker commented 5 years ago

I'm experiencing the same problem as @charger. I've added backtraces of the crash (With Domoticz debug build, using external and built-in sqlite version) to https://github.com/domoticz/domoticz/issues/2972. Interestingly, it crashes inside sqlite code, on a call which has been executed numerous times before (e.g. during startup), so it is unclear why during JSON API call it causes a crash.

Like with @charger, the debian build of cgatay/domoticz:10603-beta-deb does not crash, but due to other problems with this image I cannot switch.

idekker commented 5 years ago

The issue seems to be resolved in https://github.com/linuxserver/docker-domoticz/tree/76fd7c14-ls14. Possibly due to the bump to Alpine Linux 3.9.

tobbenb commented 5 years ago

Then I'll close the issue