50_SSChatBot - Integration des Synology Chat Servers

Begonnen von DS_Starter, 25 November 2019, 07:56:56

Vorheriges Thema - Nächstes Thema

SeppiDeluxe

Also scheinbar unterscheidet sich meine Konf... denn leider erhalte ich in V5 nicht den Umfang

defmod SeppiChat SSChatBot XXX YYY https
attr SeppiChat DbLogExclude .*
attr SeppiChat allowedUserForGet fhemchat
attr SeppiChat allowedUserForOwn fhemchat
attr SeppiChat allowedUserForSet fhemchat
attr SeppiChat defaultPeer fhemchat
attr SeppiChat httptimeout 60
attr SeppiChat room Chat
attr SeppiChat showTokenInLog 0
attr SeppiChat verbose 5

setstate SeppiChat Error
setstate SeppiChat 2023-05-19 10:03:17 Error malformed JSON string received
setstate SeppiChat 2023-05-19 10:03:17 Errorcode 9000
setstate SeppiChat 2023-05-19 10:03:17 QueueLength 656
setstate SeppiChat 2023-05-19 10:03:17 state Error

2023.05.19 10:01:18 4: SeppiChat - ####################################################
2023.05.19 10:01:18 4: SeppiChat - ###         start Chat operation sendItem
2023.05.19 10:01:18 4: SeppiChat - ####################################################
2023.05.19 10:01:18 4: SeppiChat - API hashvalues already set - ignore get apisites
2023.05.19 10:01:18 4: SeppiChat - botToken read from RAM: ********
2023.05.19 10:01:18 4: SeppiChat - start SendQueue entry index "2" (sendItem) for operation.
2023.05.19 10:01:18 5: SeppiChat - HTTP-Call will be done with httptimeout: 60 s
2023.05.19 10:01:18 4: SeppiChat - Call-Out: https://synostorage.intranet.lan:20001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "UeberlauffassEntleere Fass wegen Fuellstand größer 90%25","user_ids": [9]}
2023.05.19 10:01:18 3: Audiokonverter: Der Audiokonverter ist an
2023.05.19 10:01:18 4: SeppiChat - Data returned: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

2023.05.19 10:01:18 2: SeppiChat - ERROR - "sendItem" SendQueue index "2" not executed. Restart SendQueue in 86400 s (retryCount 296).


Aber ich stimme dir zu das HTTPUTILS möglicherweise bei der Übertragung einen Unterschied "einbauen" im Gegensatz zum Brwoseraufruf.

DS_Starter

#256
Ach sorry, ich hatte das Modul schon weiterentwickelt.
Liegt erstmal in meinem Contrib.
Lade des dir bitte und dann nochmal.

Zum Download in der FHEMWEB Kommandozeile inklusive der Anführungszeichen angeben und danach FHEM restarten:

"wget -qO ./FHEM/50_SSChatBot.pm https://svn.fhem.de/fhem/trunk/fhem/contrib/DS_Starter/50_SSChatBot.pm"

Zitat&payload={"text": "UeberlauffassEntleere Fass wegen Fuellstand größer 90%25","user_ids"
Ich würde erstmal mit einem simplen Text ohne Sonderzeichen testen.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

joj

#257
Hallo DS_Starter,
hatte heute wiedereinmal Zeit. Vielen, vielen Dank für deine Nachforschungen!

Anbei habe ich Logs aus einem WireShark Capture. Einmal von FHEM zur Syno (FHEMtoSYNO) und einmal die Rückantwort (SYNOtoFHEM). Kann es sein, dass beim HTTP-GET die URI abgeschnitten wird?
Siehe Abschnitt "Hypertext Transfer Protocol" im FHEMtoSYNO Log...

Des Weiteren nochmals ein FHEM-LOG Auszug mit Verbose5 am Device aber ich bekomme hier leider nicht mehr Logging, FHEM ist eben aktualisiert worden...

2023.05.19 10:42:18 5: SynChatBot - Add Item to queue - Index 2:
{
  'retryCount' => 0,
  'opmode' => 'sendItem',
  'postid' => undef,
  'text' => 'Test1234',
  'fileUrl' => '',
  'method' => 'chatbot',
  'channel' => '',
  'userid' => 6,
  'attachment' => ''
}

2023.05.19 10:42:18 4: SynChatBot - ####################################################
2023.05.19 10:42:18 4: SynChatBot - ###        start Chat operation sendItem   
2023.05.19 10:42:18 4: SynChatBot - ####################################################
2023.05.19 10:42:18 4: SynChatBot - API hashvalues already set - ignore get apisites
2023.05.19 10:42:18 4: SynChatBot - botToken read from RAM: ********
2023.05.19 10:42:18 4: SynChatBot - start SendQueue entry index "2" (sendItem) for operation.
2023.05.19 10:42:18 5: SynChatBot - HTTP-Call will be done with httptimeout: 20 s
2023.05.19 10:42:18 4: SynChatBot - Call-Out: https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "Test1234","user_ids": [6]}
2023.05.19 10:42:18 4: SynChatBot - Data returned: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>




WireShark-LOG FHEMtoSYNO:
Frame 5: 361 bytes on wire (2888 bits), 361 bytes captured (2888 bits) on interface eth0, id 0
    Section number: 1
    Interface id: 0 (eth0)
        Interface name: eth0
    Encapsulation type: Ethernet (1)
    Arrival Time: May 19, 2023 10:05:01.402891063 Mitteleuropäische Sommerzeit
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1684483501.402891063 seconds
    [Time delta from previous captured frame: 0.003254621 seconds]
    [Time delta from previous displayed frame: 0.003254621 seconds]
    [Time since reference or first frame: 0.564617715 seconds]
    Frame Number: 5
    Frame Length: 361 bytes (2888 bits)
    Capture Length: 361 bytes (2888 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ip:tcp:http]
    [Coloring Rule Name: HTTP]
    [Coloring Rule String: http || tcp.port == 80 || http2]
Ethernet II, Src: Raspberr_d7:1f:2d (dc:a6:32:d7:1f:2d), Dst: Synology_a7:38:6e (00:11:32:a7:38:6e)
    Destination: Synology_a7:38:6e (00:11:32:a7:38:6e)
        Address: Synology_a7:38:6e (00:11:32:a7:38:6e)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: Raspberr_d7:1f:2d (dc:a6:32:d7:1f:2d)
        Address: Raspberr_d7:1f:2d (dc:a6:32:d7:1f:2d)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: IP_FHEM, Dst: IP_SYNO
    0100 .... = Version: 4
    .... 0101 = Header Length: 20 bytes (5)
    Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
        0000 00.. = Differentiated Services Codepoint: Default (0)
        .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
    Total Length: 347
    Identification: 0xdb4c (56140)
    010. .... = Flags: 0x2, Don't fragment
        0... .... = Reserved bit: Not set
        .1.. .... = Don't fragment: Set
        ..0. .... = More fragments: Not set
    ...0 0000 0000 0000 = Fragment Offset: 0
    Time to Live: 64
    Protocol: TCP (6)
    Header Checksum: 0xdcfa [validation disabled]
    [Header checksum status: Unverified]
    Source Address: IP_FHEM
    Destination Address: IP_SYNO
Transmission Control Protocol, Src Port: 57062, Dst Port: 5000, Seq: 1, Ack: 1, Len: 295
    Source Port: 57062
    Destination Port: 5000
    [Stream index: 1]
    [Conversation completeness: Complete, WITH_DATA (31)]
    [TCP Segment Len: 295]
    Sequence Number: 1    (relative sequence number)
    Sequence Number (raw): 3280250145
    [Next Sequence Number: 296    (relative sequence number)]
    Acknowledgment Number: 1    (relative ack number)
    Acknowledgment number (raw): 3387464037
    1000 .... = Header Length: 32 bytes (8)
    Flags: 0x018 (PSH, ACK)
        000. .... .... = Reserved: Not set
        ...0 .... .... = Accurate ECN: Not set
        .... 0... .... = Congestion Window Reduced: Not set
        .... .0.. .... = ECN-Echo: Not set
        .... ..0. .... = Urgent: Not set
        .... ...1 .... = Acknowledgment: Set
        .... .... 1... = Push: Set
        .... .... .0.. = Reset: Not set
        .... .... ..0. = Syn: Not set
        .... .... ...0 = Fin: Not set
        [TCP Flags: ·······AP···]
    Window: 502
    [Calculated window size: 64256]
    [Window size scaling factor: 128]
    Checksum: 0x82a3 [unverified]
    [Checksum Status: Unverified]
    Urgent Pointer: 0
    Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
        TCP Option - No-Operation (NOP)
            Kind: No-Operation (1)
        TCP Option - No-Operation (NOP)
            Kind: No-Operation (1)
        TCP Option - Timestamps
            Kind: Time Stamp Option (8)
            Length: 10
            Timestamp value: 2439349622: TSval 2439349622, TSecr 12589153
            Timestamp echo reply: 12589153
    [Timestamps]
        [Time since first frame in this TCP stream: 0.003469509 seconds]
        [Time since previous frame in this TCP stream: 0.003254621 seconds]
    [SEQ/ACK analysis]
        [iRTT: 0.000214888 seconds]
        [Bytes in flight: 295]
        [Bytes sent since last PSH flag: 295]
    TCP payload (295 bytes)
Hypertext Transfer Protocol
    GET /webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "1234","user_ids": [6]} HTTP/1.0\r\n
        [Expert Info (Chat/Sequence): GET /webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "1234","user_ids": [6]} HTTP/1.0\r\n]
            [GET /webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "1234","user_ids": [6]} HTTP/1.0\r\n]
            [Severity level: Chat]
            [Group: Sequence]
        Request Method: GET
        Request URI: /webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text":
            Request URI Path: /webapi/entry.cgi
            Request URI Query: api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text":
                Request URI Query Parameter: api=SYNO.Chat.External
                Request URI Query Parameter: version=2
                Request URI Query Parameter: method=chatbot
                Request URI Query Parameter: token="CHAT_BOT_TOKEN_HERE"
                Request URI Query Parameter: payload={"text":
        Request Version: "1234","user_ids": [6]} HTTP/1.0
    Host: IP_SYNO:5000\r\n
    User-Agent: fhem\r\n
    Accept-Encoding: gzip,deflate\r\n
    Accept: application/json\r\n
    \r\n
    [Full request URI: http://IP_SYNO:5000/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text":]
    [HTTP request 1/1]
    [Response in frame: 7]


WireShark-LOG SYNOtoFHEM:
Frame 7: 361 bytes on wire (2888 bits), 361 bytes captured (2888 bits) on interface eth0, id 0
    Section number: 1
    Interface id: 0 (eth0)
        Interface name: eth0
    Encapsulation type: Ethernet (1)
    Arrival Time: May 19, 2023 10:05:01.403064415 Mitteleuropäische Sommerzeit
    [Time shift for this packet: 0.000000000 seconds]
    Epoch Time: 1684483501.403064415 seconds
    [Time delta from previous captured frame: 0.000081778 seconds]
    [Time delta from previous displayed frame: 0.000081778 seconds]
    [Time since reference or first frame: 0.564791067 seconds]
    Frame Number: 7
    Frame Length: 361 bytes (2888 bits)
    Capture Length: 361 bytes (2888 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ethertype:ip:tcp:http:data-text-lines]
    [Coloring Rule Name: HTTP]
    [Coloring Rule String: http || tcp.port == 80 || http2]
Ethernet II, Src: Synology_a7:38:6e (00:11:32:a7:38:6e), Dst: Raspberr_d7:1f:2d (dc:a6:32:d7:1f:2d)
    Destination: Raspberr_d7:1f:2d (dc:a6:32:d7:1f:2d)
        Address: Raspberr_d7:1f:2d (dc:a6:32:d7:1f:2d)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Source: Synology_a7:38:6e (00:11:32:a7:38:6e)
        Address: Synology_a7:38:6e (00:11:32:a7:38:6e)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
    Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: IP_SYNO, Dst: IP_FHEM
    0100 .... = Version: 4
    .... 0101 = Header Length: 20 bytes (5)
    Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
        0000 00.. = Differentiated Services Codepoint: Default (0)
        .... ..00 = Explicit Congestion Notification: Not ECN-Capable Transport (0)
    Total Length: 347
    Identification: 0xfb18 (64280)
    010. .... = Flags: 0x2, Don't fragment
        0... .... = Reserved bit: Not set
        .1.. .... = Don't fragment: Set
        ..0. .... = More fragments: Not set
    ...0 0000 0000 0000 = Fragment Offset: 0
    Time to Live: 64
    Protocol: TCP (6)
    Header Checksum: 0xbd2e [validation disabled]
    [Header checksum status: Unverified]
    Source Address: IP_SYNO
    Destination Address: IP_FHEM
Transmission Control Protocol, Src Port: 5000, Dst Port: 57062, Seq: 1, Ack: 296, Len: 295
    Source Port: 5000
    Destination Port: 57062
    [Stream index: 1]
    [Conversation completeness: Complete, WITH_DATA (31)]
    [TCP Segment Len: 295]
    Sequence Number: 1    (relative sequence number)
    Sequence Number (raw): 3387464037
    [Next Sequence Number: 296    (relative sequence number)]
    Acknowledgment Number: 296    (relative ack number)
    Acknowledgment number (raw): 3280250440
    1000 .... = Header Length: 32 bytes (8)
    Flags: 0x018 (PSH, ACK)
        000. .... .... = Reserved: Not set
        ...0 .... .... = Accurate ECN: Not set
        .... 0... .... = Congestion Window Reduced: Not set
        .... .0.. .... = ECN-Echo: Not set
        .... ..0. .... = Urgent: Not set
        .... ...1 .... = Acknowledgment: Set
        .... .... 1... = Push: Set
        .... .... .0.. = Reset: Not set
        .... .... ..0. = Syn: Not set
        .... .... ...0 = Fin: Not set
        [TCP Flags: ·······AP···]
    Window: 235
    [Calculated window size: 30080]
    [Window size scaling factor: 128]
    Checksum: 0x4b80 [unverified]
    [Checksum Status: Unverified]
    Urgent Pointer: 0
    Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
        TCP Option - No-Operation (NOP)
            Kind: No-Operation (1)
        TCP Option - No-Operation (NOP)
            Kind: No-Operation (1)
        TCP Option - Timestamps
            Kind: Time Stamp Option (8)
            Length: 10
            Timestamp value: 12589156: TSval 12589156, TSecr 2439349622
            Timestamp echo reply: 2439349622
    [Timestamps]
        [Time since first frame in this TCP stream: 0.003642861 seconds]
        [Time since previous frame in this TCP stream: 0.000081778 seconds]
    [SEQ/ACK analysis]
        [iRTT: 0.000214888 seconds]
        [Bytes in flight: 295]
        [Bytes sent since last PSH flag: 295]
    TCP payload (295 bytes)
Hypertext Transfer Protocol
    HTTP/1.1 400 Bad Request\r\n
        [Expert Info (Chat/Sequence): HTTP/1.1 400 Bad Request\r\n]
            [HTTP/1.1 400 Bad Request\r\n]
            [Severity level: Chat]
            [Group: Sequence]
        Response Version: HTTP/1.1
        Status Code: 400
        [Status Code Description: Bad Request]
        Response Phrase: Bad Request
    Server: nginx\r\n
    Date: Fri, 19 May 2023 08:05:01 GMT\r\n
    Content-Type: text/html\r\n
    Content-Length: 150\r\n
        [Content length: 150]
    Connection: close\r\n
    \r\n
    [HTTP response 1/1]
    [Time since request: 0.000173352 seconds]
    [Request in frame: 5]
    [Request URI: http://IP_SYNO:5000/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text":]
    File Data: 150 bytes
Line-based text data: text/html (7 lines)
    <html>\r\n
    <head><title>400 Bad Request</title></head>\r\n
    <body>\r\n
    <center><h1>400 Bad Request</h1></center>\r\n
    <hr><center>nginx</center>\r\n
    </body>\r\n
    </html>\r\n

DS_Starter

#258
Ja schau mal eins weiter oben (#256).
Du must das Modul erst aus meinem contrib ziehen um mehr Logasusgaben zu erhalten.

ZitatKann es sein, dass beim HTTP-GET die URI abgeschnitten wird?
Ja, meine Vermutung richtete sich auf HTTPUTILS (auch weiter oben).
Das sieht komisch aus:

[Full request URI: http://ip_syno:5000/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text":]
...
        Request URI Query Parameter: payload={"text":
        Request Version: "1234","user_ids": [6]} HTTP/1.0
Allerdings erklärt es nicht den Unterschied zwischn DSM 6.2 und DSM 7.2.

Trotzdem ... nimm die V aus dem contrib und dann sehen wir auch die Calls die httputils rausgibt an die Syno.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

joj

#259
Danke, anbei das neue V5 Log...

Beste Grüße!

2023.05.19 11:26:48 5: SynChatBot - Add Item to queue - Index 2:
{
  'userid' => 6,
  'attachment' => '',
  'channel' => '',
  'postid' => undef,
  'opmode' => 'sendItem',
  'text' => 'Test1234',
  'method' => 'chatbot',
  'fileUrl' => '',
  'retryCount' => 0
}

2023.05.19 11:26:48 4: SynChatBot - ####################################################
2023.05.19 11:26:48 4: SynChatBot - ###        start Chat operation sendItem   
2023.05.19 11:26:48 4: SynChatBot - ####################################################
2023.05.19 11:26:48 4: SynChatBot - API hashvalues already set - ignore get apisites
2023.05.19 11:26:48 4: SynChatBot - botToken read from RAM: ********
2023.05.19 11:26:48 4: SynChatBot - start SendQueue entry index "2" (sendItem) for operation.
2023.05.19 11:26:48 5: SynChatBot - HTTP-Call will be done with httptimeout: 20 s
2023.05.19 11:26:48 4: SynChatBot - Call-Out >GET<: https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "Test1234","user_ids": [6]}
2023.05.19 11:26:48 3: HttpUtils url=https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test1234","user_ids": [6]} NonBlocking via https
2023.05.19 11:26:48 2: IP: IP_SYNO -> IP_SYNO
2023.05.19 11:26:48 3: HttpUtils request header:
GET /webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test1234","user_ids": [6]} HTTP/1.0
Host: IP_SYNO:5001
User-Agent: fhem
Accept-Encoding: gzip,deflate
Accept: application/json

2023.05.19 11:26:48 2: https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test1234","user_ids": [6]}: HTTP response code 400
2023.05.19 11:26:48 3: HttpUtils https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test1234","user_ids": [6]}: Got data, length: 150
2023.05.19 11:26:48 3: HttpUtils response header:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Fri, 19 May 2023 09:26:48 GMT
Content-Type: text/html
Content-Length: 150
Connection: close
2023.05.19 11:26:48 4: SynChatBot - Data returned: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

DS_Starter

Ja, danke.
Ich habe exakt den gleichen Text bei mir probiert.

Mein Ergebnis:
2023.05.19 11:33:33.403 2: https://192.168.2.10:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "Test1234","user_ids": [4]}: HTTP response code 200
2023.05.19 11:33:33.404 3: HttpUtils https://192.168.2.10:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "Test1234","user_ids": [4]}: Got data, length: 83
2023.05.19 11:33:33.405 3: HttpUtils response header:
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 19 May 2023 09:33:33 GMT
Content-Type: application/json; charset="UTF-8"
Connection: close
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
....

Dein Ergebnis:

2023.05.19 11:26:48 2: https://ip_syno:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test1234","user_ids": [6]}: HTTP response code 400
2023.05.19 11:26:48 3: HttpUtils https://ip_syno:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test1234","user_ids": [6]}: Got data, length: 150
2023.05.19 11:26:48 3: HttpUtils response header:
HTTP/1.1 400 Bad Request
Server: nginx
....

Mir sehen die Aufrufe absolut identisch aus.
Stimmt denn dein Port mit 5001 ? Hat sich da bzgl. 7.2 etwas geändert ?

PS: füge deine Ausgaben hier mit Code-Tags ein. Ist besser lesbar.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

joj

hmm, sehr komisch...
Die Port-Settings meiner syno sind alle gleich geblieben (hatte vorher DSM 7.1.1-42962-5), ich hatte eben nur den redirect von 5000 auf 5001 weggegeben, damit ich im WireShark mehr sehe, ansonsten spuckt ja HTTPS beim "Debuggen" in die Suppe.... Wenn ich meine/genannte/die selbe URI in einen Browser kopiere funktioniert alles bestes...

Wie gesagt, als ich im Leichtsinn auf DSM7.2RC aktualisierte, fiel mit nur auf, dass node.js v11 rausflog. Im ChangeLog von Synology bzgl. DSM7.2RC dürften sich ein paar "Sicherheitsupdates" für nginx etc. auch dazugesellen... Jedenfalls wars mir (wiedermal eine Lehre) nicht zu schnell auf die neuen DSM zu wechseln...

lg


DS_Starter

#262
Ich bin leider auch etwas ratlos.
Könnte mir nur vorstellen, Synology prüft auch noch den User-Agent. Dann wäre "fhem" nicht verständlich. Ist aber nur eine Vermutung.

Inzwischen hat sich Synology wieder gemeldet und würde auch weiter unterstützen:

ZitatHello Mr. Maier,

thank you very much for the quick reply.
....

But other users of our community (FHEM) use my development as well and reported this error after the update to DSM 7.2-64551.
I will ask a user with DSM 7.2-64551 to assist with troubleshooting.


Mit freundlichen Grüßen / Best Regards,

Heiko Maaz

--------------------------------------------------------------------------

Hello Mr. Maaz,
Thank you for your answer.

If I have understood correctly, then it now works again.
If other users have the same kind of problems, they can contact us at any time so that we can analyze the issue and fix the behavior.

Mit freundlichen Grüßen / Best Regards,

Wolfgang Maier
Technical Support Engineer

Ich hatte geschrieben, dass es mit DSM 6.2 (wieder) funktioniert.

D.h. ich schlage euch vor ihr macht eine Meldung bei Syno auf und lasst das Problem remote untersuchen.
Ihr könnt euch dabei auf mein Ticket #3339716 beziehen.
Ich hatte folgendes geschrieben:

I have already developed and successfully run an application for a ChatBot under DSM 6.X for a long time.
The call shown below, which ran without problems under DSM 6.x so far, brings the following error with DSM 7.2-64551:

Call-Out:

https://192.168.0.2:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "test1234","user_ids": [6]}

2023.05.05 13:29:16 4: SynChatBot - Data returned:

<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

 
The <secret> is the Token in the original Call.
What has been changed or what do I have to adjust in the call if necessary ?

Best regards,

Heiko Maaz
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

DS_Starter

Noch eine Frage.
Wie sendet ihr den String, in einer Zeile oder mit Umbrüchen, Tabulatoren o.ä. ?
Bei mir funktionieren alle Varianten tadellos.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

joj

#264
Hi,
das mit dem UserAgent tauchte ja öfters im Forum auf, ich dachte auch schon daran... Kann man den zu Testzwecken in FHEM ändern?

Jedenfalls hab ich zwar die RC installiert, habe aber ungern die Leute von Synoloy auf meiner DS drauf...
Ich hatte vor einiger Zeit einen Call bzgl. "DiskHibernate" bei Synology offen und auch dort ist leider immer die erste Antwort "...gib uns Zugriff auf dein System...".

Jedenfalls danke für deinen Einsatz, ich werde auch einen Call aufmachen, allerdings nicht um die Leute von Synology auf meine DS zu lassen, vielleicht kann man aber bei denen das "Bewusstsein" schärfen, dass mit DSM7.2 noch etwas Arbeit ansteht...

Die URI im Browser schicke ich in einer Zeile, ohne %20 oder %22 aber mit " (Anführungszeichen) für den Token, so wie die URI aus dem FHEM Logging kommt:

https://ip_syno:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "test1234","user_ids": [6]}

Aus FHEM schicke ich nur test1234, ohne Umbrüche, Leerzeichen, Tabs o.ä.

Danke & lg!

DS_Starter

Kein Problem.
Vielleicht reicht es ja wenn du die Systemlogs mitschickst oder anderweitige Logauszüge die Synology benennen kann.
Das konnte ich ja nicht liefern.

Danke für deine Mitarbeit !  :)
Alles leider nicht so einfach ...

LG
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

DS_Starter

Zitatdas mit dem UserAgent tauchte ja öfters im Forum auf, ich dachte auch schon daran... Kann man den zu Testzwecken in FHEM ändern?
Der ist in HttpUtils.pm hart verdrahtet.
Wenn du HttpUtils.pm in deinen Editor lädst, findest du zwei Stellen wo User-Agent auf fhem gesetzt wird.
Dort könntest du ändern. FHEM muß dann restartet werden.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

joj

...besten Dank, habs noch schnell versucht. Wäre zu schön gewesen...

2023.05.19 13:36:58 5: SynChatBot - Add Item to queue - Index 3:
{
  'fileUrl' => '',
  'userid' => 6,
  'postid' => undef,
  'channel' => '',
  'text' => 'Test',
  'opmode' => 'sendItem',
  'method' => 'chatbot',
  'attachment' => '',
  'retryCount' => 0
}

2023.05.19 13:36:58 4: SynChatBot - ####################################################
2023.05.19 13:36:58 4: SynChatBot - ###         start Chat operation sendItem   
2023.05.19 13:36:58 4: SynChatBot - ####################################################
2023.05.19 13:36:58 4: SynChatBot - API hashvalues already set - ignore get apisites
2023.05.19 13:36:58 4: SynChatBot - botToken read from RAM: ********
2023.05.19 13:36:58 4: SynChatBot - start SendQueue entry index "3" (sendItem) for operation.
2023.05.19 13:36:58 5: SynChatBot - HTTP-Call will be done with httptimeout: 20 s
2023.05.19 13:36:58 4: SynChatBot - Call-Out >GET<: https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="<secret>"&payload={"text": "Test","user_ids": [6]}
2023.05.19 13:36:58 3: HttpUtils url=https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test","user_ids": [6]} NonBlocking via https
2023.05.19 13:36:58 2: IP: IP_SYNO -> IP_SYNO
2023.05.19 13:36:58 3: HttpUtils request header:
GET /webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test","user_ids": [6]} HTTP/1.0
Host: IP_SYNO:5001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42
Accept-Encoding: gzip,deflate
Accept: application/json

2023.05.19 13:36:58 2: https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test","user_ids": [6]}: HTTP response code 400
2023.05.19 13:36:58 3: HttpUtils https://IP_SYNO:5001/webapi/entry.cgi?api=SYNO.Chat.External&version=2&method=chatbot&token="CHAT_BOT_TOKEN_HERE"&payload={"text": "Test","user_ids": [6]}: Got data, length: 150
2023.05.19 13:36:58 3: HttpUtils response header:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Fri, 19 May 2023 11:36:58 GMT
Content-Type: text/html
Content-Length: 150
Connection: close
2023.05.19 13:36:58 4: SynChatBot - Data returned: <html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

DS_Starter

ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

DS_Starter

Auf der Syno gibt es bei mir das Verzeichnis

 /var/log/nginx

Dort drin ein File error.log

Schau doch da mal rein.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter