Aypac / Arduino-TR-064-SOAP-Library

Arduino library for the TR-064 protocol, most commonly used by the Fritz!Box router API
Other
63 stars 21 forks source link

crash using Arduino TR-064 SOAP Library V 1.2.2 #65

Closed g-Schroeder closed 1 year ago

g-Schroeder commented 1 year ago

Problem using Arduino TR-064 SOAP Library V 1.2.2

FritzBox 7590, FritzOS 7.50 WEMOS D1 Mini Wifi connection is established Fritz!Box credentials work

I am trying to get the home-indicator sample to work, the script crashes on „init()“ in „initServiceURLs()“ in tr064.cpp

My analysis so far:

The crash occurs in the loop „while(1)“ which finds no end. Cause seems to be that in TR064::xmlTakeParam()“ the stream from which is read, seems to be empty. This causes to return two empty strings instead of serviceName and serviceUrl, which in turn misses to hit a break condition in „while(1)“

Trying to read from tr064client in „TR064::httpRequest()“ with http.readString() when the request succeed, the result also is an empty string.

A direct request in Safari via http://192.168.178.1:49000/tr64desc.xml gives me the complete description xml file

Any help would be great, thanks in advance

Günter

14:04:58.549 -> [SETUP] WAIT 4... 14:04:59.571 -> [SETUP] WAIT 3... 14:05:00.556 -> [SETUP] WAIT 2... 14:05:01.581 -> [SETUP] WAIT 1... 14:05:10.117 -> Initialize TR-064 connection 14:05:10.117 -> 14:05:10.216 -> [TR064][httpRequest] prepare request to URL: http://192.168.0.1:49000/tr64desc.xml 14:05:10.248 -> [TR064][httpRequest] GET... 14:05:10.248 -> [TR064][httpRequest] Response code: 200 14:05:10.248 -> [TR064][initServiceURLs] get the Stream 14:05:10.311 -> [TR064][initServiceURLs] 11 readServiceName: @ readServiceUrl: 14:05:10.311 -> [TR064][initServiceURLs] 12 readServiceName: @ readServiceUrl: 14:05:10.343 -> [TR064][initServiceURLs] 13 readServiceName: @ readServiceUrl: 14:05:10.343 -> [TR064][initServiceURLs] 14 readServiceName: @ readServiceUrl: 14:05:10.343 -> [TR064][initServiceURLs] 15 readServiceName: @ readServiceUrl: 14:05:10.343 -> [TR064][initServiceURLs] 16 readServiceName: @ readServiceUrl: 14:05:10.343 -> [TR064][initServiceURLs] 17 readServiceName: @ readServiceUrl: 14:05:10.343 -> [TR064][initServiceURLs] 18 readServiceName: @ readServiceUrl: 14:05:10.375 -> [TR064][initServiceURLs] 19 readServiceName: @ readServiceUrl: 14:05:10.375 -> [TR064][initServiceURLs] 20 readServiceName: @ readServiceUrl: 14:05:10.375 -> [TR064][initServiceURLs] 21 readServiceName: @ readServiceUrl: 14:05:10.375 -> [TR064][initServiceURLs] 22 readServiceName: @ readServiceUrl: … 14:05:10.826 -> [TR064][initServiceURLs] 100 readServiceName: $ �?, �?, �?�?��?�� @ readServiceUrl: 14:05:10.826 -> [TR064][initServiceURLs] 101 readServiceName: @ readServiceUrl: 14:05:10.857 -> [TR064][initServiceURLs] 102 readServiceName: @ readServiceUrl: 14:05:10.857 -> [TR064][initServiceURLs] 103 readServiceName: @ readServiceUrl: 14:05:10.857 -> [TR064][initServiceURLs] 104 readServiceName: <� @��?�� @������ @�� @ @ readServiceUrl: 14:05:10.857 -> [TR064][initServiceURLs] 105 readServiceName: �?�� @������ @�� @�Fatal exception 28(LoadProhibitedCause): 14:05:10.889 -> epc1=0x4000e149, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000100, depc=0x00000000 14:05:10.889 ->

Aypac commented 1 year ago

This looks exactly like #62 , please follow the discussion there :)

g-Schroeder commented 1 year ago

Hallo,

Danke für die schnelle Antwort, grade wollte ich nochmals ein Update geben.

Ja #62 hab ich gesehen, hab auch die neue Version probiert, und ja, der Crash ist weg.

Der init() funktioniert leider immer noch nicht: Mit dem Snippet

Serial.println("Initialize TR-064 connection"); TR064 connection.setServer(TR_PORT, TR_IP, TR_USER); connection.debug_level = connection.DEBUG_VERBOSE; connection.init();

Bekomme ich den Fehler

[TR064][initServiceURLs] initServiceUrls failed: could not connect

Der Debug-Output (mit HTTP_CLIENT) ist

13:52:46.952 -> [TR064][httpRequest] prepare request to URL: 192.168.0.1:49000/tr64desc.xml 13:52:46.952 -> [HTTP-Client][sendRequest] type: 'GET' redirCount: 0 13:52:46.952 -> [HTTP-Client] connected to 192.168.0.1:49000 13:52:46.952 -> [HTTP-Client] sending request header 13:52:46.952 -> ----- 13:52:46.952 -> GET /tr64desc.xml HTTP/1.1 13:52:46.952 -> Host: 192.168.0.1:49000 13:52:46.952 -> User-Agent: ESP8266HTTPClient 13:52:46.985 -> Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0 13:52:46.985 -> Connection: keep-alive 13:52:46.985 -> Content-Length: 0 13:52:46.985 -> 13:52:46.985 -> ----- 13:52:46.985 -> [HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK' 13:52:46.985 -> [HTTP-Client][handleHeaderResponse] RX: 'Cache-Control: max-age=120' 13:52:46.985 -> [HTTP-Client][handleHeaderResponse] RX: 'Connection: Keep-Alive' 13:52:47.016 -> [HTTP-Client][handleHeaderResponse] RX: 'Content-Length: 14126' 13:52:47.016 -> [HTTP-Client][handleHeaderResponse] RX: 'Content-Type: text/xml' 13:52:47.016 -> [HTTP-Client][handleHeaderResponse] RX: 'Date: Fri, 24 Feb 2023 12:52:46 GMT' 13:52:47.016 -> [HTTP-Client][handleHeaderResponse] RX: 'ETag: "D281F22E5A118AD5"' 13:52:47.016 -> [HTTP-Client][handleHeaderResponse] RX: 'Expires: Fri, 24 Feb 2023 12:54:46 GMT' 13:52:47.048 -> [HTTP-Client][handleHeaderResponse] RX: 'Last-Modified: Wed, 22 Feb 2023 14:53:55 GMT' 13:52:47.048 -> [HTTP-Client][handleHeaderResponse] RX: 'Mime-Version: 1.0' 13:52:47.048 -> [HTTP-Client][handleHeaderResponse] RX: 'Keep-Alive: timeout=60, max=300' 13:52:47.048 -> [HTTP-Client][handleHeaderResponse] RX: '' 13:52:47.048 -> [HTTP-Client][handleHeaderResponse] code: 200 13:52:47.048 -> [HTTP-Client][handleHeaderResponse] size: 14126 13:52:47.081 -> [TR064][httpRequest] GET... 13:52:47.081 -> [TR064][httpRequest] Response code: 200 13:52:48.071 -> [TR064][initServiceURLs] initServiceUrls failed: could not connect

Das Snippet

Serial.println("get tr64desc.xml via http.GET()"); WiFiClient client; HTTPClient http; http.begin(client, TR_IP, TR_PORT, "/tr64desc.xml", true); int httpResponseCode = http.GET(); if (httpResponseCode > 0) { Serial.print("HTTP Response code: "); Serial.println(httpResponseCode); String payload = http.getString(); Serial.println(payload); } else { Serial.print("Error code: "); Serial.println(httpResponseCode); } http.end();

funktioniert und liefert mir die korrekte XML-Beschreibung.

Bin für jede Hilfe dankbar Grüsse Günter Schröder

Am 24.02.2023 um 13:40 schrieb René Vollmer @.***>:

This looks exactly like #62 https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/62 , please follow the discussion there :)

— Reply to this email directly, view it on GitHub https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/65#issuecomment-1443630548, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6B4BY4WG2MNVUZYSLKMMHDWZCT35ANCNFSM6AAAAAAVEKDHMA. You are receiving this because you authored the thread.

g-Schroeder commented 1 year ago

So, ich hab mal weiter versucht die TR064 Lib zum laufen zu bekommen. Ich hab mal versucht direkt einen Action-Call aufzurufen, ging ebenfalls daneben, mit einer anderen Fehlermeldung.

Hier der Aufruf der Action:

String params[][2] = {{"NewDeflectionId", "0"},{"NewEnable", "1"}}; String req[][2] = {{}}; connection.action("urn:dslforum-org:service:X_AVM-DE_OnTel:1","SetDeflectionEnable", params, 2, req, 0);

Und hier das Ergebnis:

11:08:01.862 -> [TR064][httpRequest] prepare request to URL: 192.168.0.1:49000/tr64desc.xml 11:08:01.893 -> [TR064][httpRequest] GET... 11:08:01.893 -> [TR064][httpRequest] Response code: 200 11:08:02.915 -> [TR064][initServiceURLs] initServiceUrls failed: could not connect 11:08:02.915 -> TR064_checkPresenceByMAC(9A:D5:A5:96:0F:52) 11:08:02.947 -> [TR064][action] with extraction 11:08:02.947 -> [TR064][cleanOldServiceName] searching for prefix in servicename: urn:dslforum-org:service:X_AVM-DE_OnTel:1 11:08:02.947 -> [TR064][action_raw] with parameter, NewDeflectionId 11:08:02.947 -> [TR064][action_raw] with parametervalue, 0 11:08:02.947 -> [TR064][action_raw] with parameter, NewEnable 11:08:02.947 -> [TR064][action_raw] with parametervalue, 1 11:08:02.947 -> [TR064][httpRequest] URL is empty, abort http request. 11:08:02.979 -> [TR064][action] Request Failed 11:08:02.979 ->

Aypac commented 1 year ago

Hallo @g-Schroeder , wenn du kein .init machst, musst du manuell die controlURL angeben. Also vermutlich: connection.action("urn:dslforum-org:service:X_AVM-DE_OnTel:1","SetDeflectionEnable", params, 2, req, 0, "/upnp/control/x_contact");

Bitte folge auch dem anderen Thread #62 .

g-Schroeder commented 1 year ago

Hello Rene,

Thanks for the hint to the missing URL in connection.action, using this causes no more error, but does not deliver any values. Following thread #62 I finally got the same results as TritonX concerning the attempt to get authenticated. I cannot get an Authentication, and yes I double checked the Realm, username (uid), password (pw) and nonce (sn).

One more thing: I am fighting since some time installing the newest version of the TR064 library. The newest version (1.2.3) does not appear in the Library Manager. I installed the version 1.2.2 manually via ZIP. After uninstalling the version 1.2.2 in the Library Manager and installing the 1.2.3 via ZIP, the Library Manager shows still 1.2.2 as installed, but the Sketch uses the Version 1.2.3 (which I verified via a debugging print in tr064.cpp)

Any ideas about this, sorry for annoying you Regards Günter

Am 14.03.2023 um 12:49 schrieb René Vollmer @.***>:

Hallo @g-Schroeder https://github.com/g-Schroeder , wenn du kein .init machst, musst du die URL angeben. Bitte folge auch dem anderen Thread #62 https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/62 .

Please check out dd04576e https://github.com/Aypac/Arduino-TR-064-SOAP-Library/commit/dd04576e3ae0fd2140e0d125e1b01fb7a46e5b6d = latest version on develop. I think it should fix your problems - if your call is actually valid (which I cannot test as I do not have DECT phones). Please try the Internet_Stats.ino example. If that one works, but your code does not, please try the manual debugging from my previous post.

— Reply to this email directly, view it on GitHub https://github.com/Aypac/Arduino-TR-064-SOAP-Library/issues/65#issuecomment-1467952594, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6B4BY4STO7RWG26JJRZUITW4BLKZANCNFSM6AAAAAAVEKDHMA. You are receiving this because you were mentioned.