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

HTTP-Error 500 #38

Closed oe8bck closed 2 years ago

oe8bck commented 3 years ago

I would like to implement a very basic WLAN doorbell. So I installed this library and adapted the example caller But it does not what I expect.

So I enabled the debugger with the line

connection.TR_DEBUG_level=TR_DEBUG_VERBOSE;

in the function setup(). This is the output

[action]<error> nonce/realm request not successful!
[action]<error> Retrying in 5s
[HTTP] prepare request to URL: http://192.168.188.254:49000
[HTTP] Posting XML:
---------------------------------
<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Header><h:InitChallenge xmlns:h="http://soap-authentication.org/digest/2001/10/" s:mustUnderstand="1"><UserID>tr064</UserID></h:InitChallenge ></s:Header><s:Body><u:X_AVM-DE_DialNumber xmlns:u='urn:dslforum-org:service:X_VoIP:1'><NewX_AVM-DE_PhoneNumber>**790</NewX_AVM-DE_PhoneNumber></u:X_AVM-DE_DialNumber></s:Body></s:Envelope>
---------------------------------

[HTTP] POST... SOAPACTION: 'urn:dslforum-org:service:X_VoIP:1#X_AVM-DE_DialNumber'
[HTTP] request code: 500
[HTTP] Received back
---------------------------------

What does it mean? The IP of my 7490 (with FRITZ!OS: 07.21) is 192.168.188.254 and I added a user tr064 therein and if I call **790 from an analog phone, all the telephones ring, so the short-dial works.

Maybe somebody can help me?

Aypac commented 3 years ago

Dear oe8bck,

glad to hear you also found a good use for the lib. I cannot see just from the error message what is wrong (especially without the return XML). Did you go through the debug info on the Wiki?

Aypac commented 3 years ago

Also, did you set a pw? There is still this bug/enhancement.

oe8bck commented 3 years ago

Thanks for the fast response!

Yes, I did enable the debug messages DEBUGVERBOSE, see the first post for the outputs. I created the user tr064 with a password and set the variables fuser and fpass accordingly with rights for settings, voice and smart home. I enabled the dial assistance but not for DECT but for the analog phone attached at FON 1. The speed dial **790_ works from this phone.

The error given is #500 which is

500 Internal Server Error A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.

I think this is a hint that something in the Fritz.Box server, although there is no entry in the log of the FB (at least I do not see anything on the web interface). I am using the latest FRITZ!OS: 07.21

So I checked the WIKI and gave the debug output and I think that I set everything that's needed. What else? Is there a possiblity to get mor logs from the FB?

Aypac commented 3 years ago

You can find a log inside the FB (I cannot tell you where exactly, because it is different in each model - if you can't find it check the manual for your model), but most of the time the TR-064 errors are not caught by it though.

Could you also add the code here? Did you try this?

The only other thing that comes to mind is to manually check the request, with your browser as described at the very end here.

oe8bck commented 3 years ago

I did try the other example home-indicator. But this also cannot connect:

[HTTP] prepare request to URL: http://192.168.188.254:49000
[HTTP] Posting XML:
---------------------------------
<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Header><h:InitChallenge xmlns:h="http://soap-authentication.org/digest/2001/10/" s:mustUnderstand="1"><UserID>tr064</UserID></h:InitChallenge ></s:Header><s:Body><u:GetGenericAssociatedDeviceInfo xmlns:u='urn:dslforum-org:service:WLANConfiguration:1'><NewAssociatedDeviceIndex>1</NewAssociatedDeviceIndex></u:GetGenericAssociatedDeviceInfo></s:Body></s:Envelope>
---------------------------------

[HTTP] POST... SOAPACTION: 'urn:dslforum-org:service:WLANConfiguration:1#GetGenericAssociatedDeviceInfo'
[HTTP]<Error> Failed, message: 'connection failed'
[HTTP]<Error> Trying again in 1s.
[HTTP] prepare request to URL: http://192.168.188.254:49000
[HTTP] Posting XML:
---------------------------------
<?xml version="1.0"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Header><h:InitChallenge xmlns:h="http://soap-authentication.org/digest/2001/10/" s:mustUnderstand="1"><UserID>tr064</UserID></h:InitChallenge ></s:Header><s:Body><u:GetGenericAssociatedDeviceInfo xmlns:u='urn:dslforum-org:service:WLANConfiguration:1'><NewAssociatedDeviceIndex>1</NewAssociatedDeviceIndex></u:GetGenericAssociatedDeviceInfo></s:Body></s:Envelope>
---------------------------------

[HTTP] POST... SOAPACTION: 'urn:dslforum-org:service:WLANConfiguration:1#GetGenericAssociatedDeviceInfo'
[HTTP]<Error> Failed, message: 'connection failed'
[HTTP]<Error> Giving up.
[action]<error> nonce/realm request not successful!
[action]<error> Retrying in 5s
[action] no nonce/realm found. requesting...

BTW I have also a FB 7930 with FRITZ!OS: 06.86 but with the same behaviour.

Was there a recent change with respect to login resp. HTTPS? I will try to do it manually with a SOAP plugin. This I do not know, yet so it will take a little bit of time.

oe8bck commented 3 years ago

I did not find a browser add-on but an example in PHP with WDSL . This works!

$ php -a
Interactive mode enabled

php > $client = new SoapClient('wsdl/tr64desc/DeviceInfo.wsdl', [
php (    'login' => 'tr064',
php (    'password' => 'password'
php ( ]);
php > var_dump($client->GetInfo());

array(12) {
  ["NewManufacturerName"]=>
  string(3) "AVM"
  ["NewManufacturerOUI"]=>
  string(6) "00040E"
  ["NewModelName"]=>
  string(14) "FRITZ!Box 7490"
  ["NewDescription"]=>
  string(24) "FRITZ!Box 7490 113.07.21"
  ["NewProductClass"]=>
  string(9) "FRITZ!Box"
  ["NewSerialNumber"]=>
  string(12) "3810D5BBxxxx"
  ["NewSoftwareVersion"]=>
  string(9) "113.07.21"
  ["NewHardwareVersion"]=>
  string(14) "FRITZ!Box 7490"
  ["NewSpecVersion"]=>
  string(3) "1.0"
  ["NewProvisioningCode"]=>
  string(0) ""
  ["NewUpTime"]=>
  int(330772)
  ["NewDeviceLog"]=>
  string(1158) "29.12.20 18:49:15 Internetverbindung wurde erfolgreich erneuert. IP-Adresse: 88.x.x.x, DNS-Server: 213.x.x.x und 80.x.x.x, Gateway: 88.x.x.x
..."
}

So you can see the last login but there are no fails regarding incorrect user/pass.

No I'll try to get the PHP working with "X_AVM-DE_DialNumber"

BTW did you read the blue box in https://avm.de/service/schnittstellen/ ?

Aypac commented 3 years ago

Thanks for the info on the updated API. At first glance, it does not look like it is a major change and only concerns you have not created a dedicated user for the TR-064, which I would recommend in any case. I'll check when I have some more time at hand.

Do you have a line where you do .init() on the lib? It should not be required in the latest version of the lib and I remember, that I was suspecting, that the called function does not exist on all FB's.

oe8bck commented 3 years ago

I am not 100% sure that I got your question correctly. I added this to my sketch:

TR064 connection(PORT, IP, fuser, fpass);
...
  Serial.print("Establishing Connection...");
  connection.TR_DEBUG_level=TR_DEBUG_VERBOSE; 
  connection.init();
  Serial.println(" done");

Serial output is

Establishing Connection...[HTTP] prepare request to URL: http://192.168.188.254:49000/tr64desc.xml
[HTTP] GET...
[HTTP]<Error> Failed, message: 'read Timeout'
[HTTP]<Error> Trying again in 1s.
[HTTP] prepare request to URL: http://192.168.188.254:49000/tr64desc.xml
[HTTP] GET...
[HTTP]<Error> Failed, message: 'read Timeout'
[HTTP]<Error> Giving up.
Detected Services:
 done

If I fire http://192.168.188.254:49000/tr64desc.xml in my web browser, the connection is also not possible, same for http://fritz.box:49000/tr64desc.xml. Is the port number 49000 correct?

Aypac commented 3 years ago

What I meant was to try to comment out the line connection.init();. But if you cannot call either one of these links in your webbrowser, that is the real problem right there. Are you using a fritz!box or another type of router? Can you reach the login-interface via http://fritz.box, https://fritz.box, http://192.168.188.254, or https://192.168.188.254? The port is the standard for FB's, as far as I know. But it could in theory of course be different for other manufacturers and/or models. Maybe try to find some info on that in the settings of your router?

Aypac commented 3 years ago

BTW, are you sure 192.168.188.254 is correct? It seems a rather uncommon IP for a router...

oe8bck commented 3 years ago

All the 4 links from the previous post work and I did change the IP by intention - I do not like standard IPs, usernames or passwords...

I used the Ringer example and there is no .init in it. When I add it, there is a read time-out when accessing http://192.168.188.254:49000/tr64desc.xml

Aypac commented 3 years ago

Ok, but as long as the tr64desc.xml is not reachable via the browser I think the fault does not lie with the library. So I cannot really help you I think :/ Maybe try a different FB, try to update the firmware, or make a backup of the settings and reset them to default and see if it works then.

Other than that I only see this rather dirty hack: since the calls themselves seem to work, you could also hack the function that calls the xml and just hard-code the URLs you need into the according array. Maybe something like this:

void TR064::initServiceURLs() {
    String inStr = "put you fake XML here:<service><serviceType>DeviceInfo</serviceType><controlURL>wsdl/tr64desc/DeviceInfo.wsdl</controlURL></service>";
    // rest of the function remains the same
}
Aypac commented 2 years ago

No new developments here.