"Health-Check" via REST API

Stimmt.
curl -X GET http://192.168.178.202:2001/healthcheck.php kommt aber leider zum gleichen Ergebnis.

1 Like

Ja, davon ging ich aus… war nur gerade ein kleiner Knoten in meinem Kopf :wink:

Also hier funktioniert es:

root@homegear:/# curl -X GET http://localhost:2001/healthcheck.php
{"status": 0}root@homegear:/#

Bekommst du einen Fehler auf der Konsole zurück? Auf welchem System führst du das Ganze aus?

Nein, auf der Console kommt kein Fehler. Ich sehe nur den entsprechenden Fehler dann im HomeGear Log.

Ich führe das Kommando von einem Raspbian im gleichen Subnet aus.

pi@fritz:~ $ sudo curl -X GET http://192.168.178.202:2001/healthcheck.php
pi@fritz:~ $

Im HomeGear Container selbst habe ich kein curl zur Verfügung, aber wget liefer mir folg.:

--2018-08-24 09:11:09--  http://localhost:2001/healthcheck.php
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:2001... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2018-08-24 09:11:09 ERROR 500: Internal Server Error.

mit der gleichen Meldung im Log:

08/24/18 09:53:34.467 Script engine (/var/lib/homegear/www/rpc/healthcheck.php): PHP Fatal error:  Unknown: Failed opening required '/var/lib/homegear/www/rpc/healthcheck.php' (include_path='.:/var/lib/homegear/phpinclude') in Unknown on line 0

Mit Homegear Stable im amd64-Docker-Container klappt es bei mir ebenso. Ein Berechtigungsproblem ist es nicht, dann gibt es einen Fehler 404. Was ist dein Hostsystem? Welches Homegear-Image verwendest du genau? Ich muss das Problem hier reproduzieren können, um mehr dazu sagen zu können. Bisher gab es mit der generellen Ausführung von PHP - soweit mir bekannt - noch nie irgendwelche Probleme. Funktioniert bei dir die Seite “http://192.168.178.202:2001”, wenn du diese mit einem Browser öffnest? Hast du die Datei /etc/homegear/rpcservers.conf modifiziert?

Viele Grüße

Sathya

1 Like

Hostsystem: Raspbian Stretch auf einem Raspberry 3B
HomeGear-Image: rpi-homegear:latest

Ja, das Webinterface http://192.168.178.202:2001 sowie die Kommmunikation mit HomeAssistant und auch die REST API Aufrufe z.B.: via http://192.168.178.202:2001/api/v1/get/13/0/UNREACH funktionieren problemlos.

Bei mir verhält sich ja das ganze Docker Image etwas seltsam. Funktioniert bei mir ja nur mit einem etwas experimentellen Aufruf.
Siehe Thread: Docker: No family modules found in "/var/lib/homegear/modules/" / No xml files found in "/etc/homegear/devices/0/"

Meine ‘rpcservers.conf’ sieht so aus - Ich glaube nicht, dass ich Sie mal verändert habe.

[RPCServer1]
# Interface to bind the RPC server to. By default IPv4 and IPv6 are
# enabled. If you want to only use IPv4 set "interface" to "0.0.0.0".
# Default: interface = 0.0.0.0
interface = 0.0.0.0

# The port number to bind the RPC server to. This setting is mandatory.
port = 2001

# Enable Homegear's XML-RPC and binary RPC server on this port. 
# Default: true
xmlrpcServer = true

# Enable Homegear's JSON-RPC server on this port. 
# Default: true
jsonrpcServer = true

# Enable Homegear's build-in web server on this port
# Default: false
webServer = true

# Enable Homegear's REST server on this port
# Default: false
restServer = true

# Path to static web content used by the web server
# Default: /var/lib/homegear/www
contentPath = /var/lib/homegear/www/rpc

# Default: contentPathPermissions = 550
# contentPathPermissions = 550

# Default: contentPathUser =
# contentPathUser = homegear

# Default: contentPathGroup =
# contentPathGroup = homegear

# Enable Homegear's build-in WebSocket server on this port
# WARNING: Enabling Websockets without authentication is a high security risk!
# So make sure, webSocketAuthType is not set to none!
# Default: false
webSocket = true

# Set ssl to "true" to enable SSL support
ssl = false

# You can specify the authentication types you want to enable here.
# Can be one or more of the following (seperated by ","):
# - none: No authentication is required
# - basic: Use basic authentication
# - cert: Use certificate authentication (only works when "ssl" is "true")
# Default: authType = cert
authType = none

# You can specify the websocket authentication type here. Never ever use basic auth
# over an unencrypted connection!
# Can be one of the following: none, basic, session
# "session" checks for the PHP session variable "authorized", which must be set to
# "true" for the authentication to succeed.
# Default: webSocketAuthType = session
webSocketAuthType = session

# Comma separated list of accepted group IDs. Only relevant when authType or webSocketAuthType are specified.
validGroups = 1

Sorry für die späte Antwort. Ich bekomme das Problem hier leider nicht reproduziert. Die Einstellungen sehen soweit gut aus. Und die index.php geht ja bei dir, d. h. PHP funktioniert generell. Klappt es, wenn du die healthcheck.php in index.php umbenennst?

Danke für die Rückmeldung!
Tatsächlich sieht das etwas anders im Log aus, funktioniert aber (noch) nicht:

10/24/18 12:56:24.879 Script Engine Server: Info: Starting script "/var/lib/homegear/www/rpc/index.php" with id 1.
10/24/18 12:56:24.935 Script Engine Server: Info: Client number 0 is calling RPC method: scriptHeaders
10/24/18 12:56:24.938 Info: Script with id 1 finished with exit code 255

Was sagt das homegear-scriptengine.log?

Leider die gleiche Meldung wie zuvor:

10/31/18 01:42:20.600 Script engine (/var/lib/homegear/www/rpc/index.php): PHP Fatal error:  Unknown: Failed opening required '/var/lib/homegear/www/rpc/index.php' (include_path='.:/var/lib/homegear/phpinclude') in Unknown on line 0
10/31/18 01:42:20.604 Info: Script 1 exited with code 255.

Das ist doch aus der Datei homegear.log? In der homegear-scriptengine.log sind unter Umständen mehr Informationen.