question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail calling WANPPPConnection1/GetInfo

See original GitHub issue

I created a minimum example showing the issue:

#!/usr/bin/env python 

from fritzconnection import FritzConnection
import sys
import os

FRITZBOX_IP = os.environ.get('TGFB_IP', '192.168.178.1')
FRITZBOX_USER = os.environ.get('TGFB_USER', 'telegraf')
FRITZBOX_PASSWORD = os.environ.get('TGFB_PASSWD')
FRITZBOX_ID = os.environ.get('TGFB_ID', 'FrizBox')

def readfritz(module, action):
    try:
        answer= fc.call_action(module, action)
    except BaseException:
        print(f"Could not query {module} with action {action}")
        raise
    return answer

try:
    print(f"Connecting to {FRITZBOX_IP} as user {FRITZBOX_USER}")
    fc = FritzConnection(address=FRITZBOX_IP, user=FRITZBOX_USER, password=FRITZBOX_PASSWORD, timeout=5.0)
except BaseException:
    print("Cannot connect to fritzbox.")
    sys.exit(1)


deviceInfo = readfritz('DeviceInfo1', 'GetInfo')
print(f"connected to {deviceInfo['NewModelName']}")

connectionInfo = readfritz('WANPPPConnection1', 'GetInfo') 
print(connectionInfo)

When ran with, it fails with:

$ TGFB_IP=192.168.0.1 TGFB_USER=someuser TGFB_PASSWD=secret python3 ./test.py
Connecting to 192.168.0.1 as user someuser
connected to FRITZ!Box 6490 Cable (lgi)
Could not query WANPPPConnection1 with action GetInfo
Traceback (most recent call last):
  File "./test.py", line 31, in <module>
    connectionInfo = readfritz('WANPPPConnection1', 'GetInfo') 
  File "./test.py", line 14, in readfritz
    answer= fc.call_action(module, action)
  File "/usr/local/lib/python3.8/site-packages/fritzconnection/core/fritzconnection.py", line 218, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.8/site-packages/fritzconnection/core/soaper.py", line 233, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.8/site-packages/fritzconnection/core/soaper.py", line 218, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.8/site-packages/fritzconnection/core/soaper.py", line 147, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzActionError: UPnPError: 
errorCode: 401
errorDescription: Invalid Action

This was obviously ran with a valid user and password.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kbrcommented, Aug 10, 2020

@chevdor: I can reproduce this with a 4020, which is able to run the WANPPPConnection1 service behind a DSL-modem, but – as a separate access point – is not configured this way. The box reports that the service exists but every action fails, as the service seems to be not in use.

According to the AVM documentation https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/wanpppconnSCPD.pdf it may be that the WANPPPConnection1 service is also not in use for your type of cable connection as it is typically used by AVM for products with a DSL interface.

In this case AVM recommends to check the type of connection by inspection the Layer3Forwarding. For my 4020 this returns (corresponding to the configuration):

>>> r = fc.call_action('Layer3Forwarding', 'GetDefaultConnectionService')
>>> r
{'NewDefaultConnectionService': '1.WANIPConnection.1'}
>>> 

0reactions
chevdorcommented, Aug 10, 2020

Awesome @kbr. I think you pinned it. I am closing this issue as I think we can move on when calling the correct method as you suggested.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[FritzBox TR-064] Can´t get WAN IP address #5283 - GitHub
Hi! There´s an problem with the FritzBox TR-064 binding that results in some errors when trying to get the current WAN IP address....
Read more >
fritzconnection - PyPI
fritzcall.py Gives access to recent phone calls: incoming, outgoing and ... info = connection.call_action('WANIPConnection:2', 'GetInfo').
Read more >
DGN1000v3 Firmware Version 1.0.0.22 - NETGEAR Support
Fixed SOAP security issue; Fixed the SSL POODLE vulnerability issue; Modified the WANIPConnection::GetInfo SOAP API to return the default MAC address even ...
Read more >
Why UPNP gives me error 501 even thought the Curl ... - Reddit
i am trying to use the UPNP on my router but keeps giving me the 501 error. the command i am using
Read more >
fritzbox - npm
This library is capable of: Supports the UPnP and TR-064 specification of the Fritz!Box; Call actions of services; Authentication with username/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found