Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fritzconnection --reconnect and fritzstatus seems to use a no longer existing service name #236

Open
calestyo opened this issue Nov 11, 2024 · 10 comments

Comments

@calestyo
Copy link

Hey.

At least on my 7590 AX with version 8.0 it says:

$ fritzconnection -e -u foo -p bar --reconnect

fritzconnection v1.14.0
FRITZ!Box 7590 AX at https://cerf
FRITZ!OS: 8.0

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/fritzconnection/core/fritzconnection.py", line 453, in call_action
    service = self.device_manager.services[service_name]
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'WANIPConn1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/fritzconnection", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3/dist-packages/fritzconnection/cli/fritzinspection.py", line 167, in main
    execute()
  File "/usr/lib/python3/dist-packages/fritzconnection/cli/fritzinspection.py", line 162, in execute
    run_inspector(inspector, args)
  File "/usr/lib/python3/dist-packages/fritzconnection/cli/fritzinspection.py", line 150, in run_inspector
    inspector.fc.reconnect()
  File "/usr/lib/python3/dist-packages/fritzconnection/core/fritzconnection.py", line 507, in reconnect
    self.call_action("WANIPConn1", "ForceTermination")
  File "/usr/lib/python3/dist-packages/fritzconnection/core/fritzconnection.py", line 455, in call_action
    raise FritzServiceError(f'unknown service: "{service_name}"')
fritzconnection.core.exceptions.FritzServiceError: unknown service: "WANIPConn1"

There are however the following commands shown in introspection:

Service:            WANPPPConnection1
Action:             ForceTermination
Parameters:

    Name                                  direction     data type
...
Service:            WANIPConnection1
Action:             ForceTermination
Parameters:

    Name                                  direction     data type

So I guess WANIPConn1 was simply renamed to WANIPConnection1?


Similarly:

$ fritzstatus -e -u foo -p bar 

fritzconnection v1.14.0
FRITZ!Box 7590 AX at https://cerf
FRITZ!OS: 8.0

FritzStatus:

    is linked             : unsupported attribute "is_linked"
    is connected          : unsupported attribute "is_connected"
    external ip (v4)      : unsupported attribute "external_ip"
    external ip (v6)      : unsupported attribute "external_ipv6"
    internal ipv6-prefix  : unsupported attribute "ipv6_prefix"
    uptime                : unsupported attribute "str_uptime"
    bytes send            : unsupported attribute "bytes_sent"
    bytes received        : unsupported attribute "bytes_received"
    max. bit rate         : unsupported attribute "str_max_bit_rate"

Looking in the code, these seem to use WANIPConn (**note that here the code doesn't have the trailing 1 as above) but my FritzBox shows e.g. the following commands in introspection, e.g. for the external IP:

Service:            WANPPPConnection1
Action:             GetExternalIPAddress
Parameters:

    Name                                  direction     data type

    NewExternalIPAddress                     out ->     string
...
Service:            WANIPConnection1
Action:             GetExternalIPAddress
Parameters:

    Name                                  direction     data type

    NewExternalIPAddress                     out ->     string

So might be named differently in newer firmwares?

Thanks,
Chris.

@kbr
Copy link
Owner

kbr commented Nov 12, 2024

Way back in older OS versions there have been the two Services WANIPConn1 and WANIPConnection1 with partly overlapping functionality. So it could be that the description for WANIPConn1 has been silently removed in OS 8 by AVM. If this is the case there should be a fix, because this is a breaking change in FritzOS. This is not to hard, so hopefully I can care about it soon.

@calestyo
Copy link
Author

Would a complete dump of fritzconnection -c help you?

It also seems that some of the properties might have changed. In some small Python test prog using the lib, I couldn’t find the external IPv6 address at all, and the IPv4 only in WANPPPConnection1 not WANIPConnection1.

@calestyo
Copy link
Author

calestyo commented Nov 14, 2024

$ ptpython3
>>> import fritzconnection
>>> fc = fritzconnection.FritzConnection(address="foo",password="bar",user="baz")

I think currently in the code you use X_AVM_DE_GetExternalIPv6Address,... but that no longer seems to exist:

>>> fc.call_action(service_name="WANIPConnection1",action_name="X_AVM_DE_GetExternalIPv6Address")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/fritzconnection/core/fritzconnection.py", line 456, in call_action
    return self.soaper.execute(service, action_name, arguments)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/fritzconnection/core/soaper.py", line 286, in execute
    return handle_response(response)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/fritzconnection/core/soaper.py", line 268, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/lib/python3/dist-packages/fritzconnection/core/soaper.py", line 191, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzActionError: UPnPError: 
errorCode: 401
errorDescription: Invalid Action

Neither that:

>>> fc.call_action(service_name="WANIPConnection1",action_name="GetExternalIPAddress")
{'NewExternalIPAddress': ''}

I found the external IPv4 in WANPPPConnection1:

>>> fc.call_action(service_name="WANPPPConnection1",action_name="GetInfo")
{'NewEnable': True, 'NewConnectionStatus': 'Connected', 'NewPossibleConnectionTypes': 'IP_Routed, IP_Bridged', 'NewConnectionType': 'IP_Routed', 'NewName': 'internet', 'NewUptime': 161144, 'NewUpstreamMaxBitRate': 36294339, 'NewDownstreamMaxBitRate': 29347045, 'NewLastConnectionError': 'ERROR_NONE', 'NewIdleDisconnectTime': 0, 'NewRSIPAvailable': False, 'NewUserName': '[email protected]', 'NewNATEnabled': True, 'NewExternalIPAddress': '1.2.3.4', 'NewDNSServers': '2003:180:2:7000::53, 2003:180:2:9000::53,217.237.151.115,217.237.148.102', 'NewMACAddress': '11:22:33:44:55:66', 'NewConnectionTrigger': 'AlwaysOn', 'NewLastAuthErrorInfo': '', 'NewMaxCharsUsername': 128, 'NewMinCharsUsername': 3, 'NewAllowedCharsUsername': '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._@()#/%[]{}*+§$&=?!:;,', 'NewMaxCharsPassword': 64, 'NewMinCharsPassword': 3, 'NewAllowedCharsPassword': '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._@()#/%[]{}*+§$&=?!:;,', 'NewTransportType': 'PPPoE', 'NewRouteProtocolRx': 'Off', 'NewPPPoEServiceName': '', 'NewRemoteIPAddress': '', 'NewPPPoEACName': 'MUNJ10', 'NewDNSEnabled': True, 'NewDNSOverrideAllowed': True}

But not in the counterpart in WANIPConnection1:

>>> fc.call_action(service_name="WANIPConnection1",action_name="GetInfo")
{'NewEnable': True, 'NewConnectionStatus': 'Connecting', 'NewPossibleConnectionTypes': 'IP_Routed, IP_Bridged', 'NewConnectionType': 'IP_Routed', 'NewName': 'mstv', 'NewUptime': 0, 'NewLastConnectionError': 'ERROR_NONE', 'NewRSIPAvailable': False, 'NewNATEnabled': True, 'NewExternalIPAddress': '', 'NewDNSServers': '0.0.0.0, 0.0.0.0', 'NewMACAddress': '11:22:33:99:88:77', 'NewConnectionTrigger': 'AlwaysOn', 'NewRouteProtocolRx': 'Off', 'NewDNSEnabled': True, 'NewDNSOverrideAllowed': False}

@mib1185
Copy link
Contributor

mib1185 commented Nov 17, 2024

I've a 7530 ax and updated from 7.81 to 8.00 - i captured the fritzconnection -c from both versions. There is not any service renamed, just some additions to existing services - feel free to compare both files:

fritz_all_apis_7.81.txt
fritz_all_apis_8.00.txt

@kbr
Copy link
Owner

kbr commented Nov 17, 2024

@mib1185 : thanks for posting both files. I'v missed to export the api-listing before updating my 7590 from 7.57 to 8.0. Just listing the servicenames (with -s) shows that WANIPConn1 has not been removed. So currently I asume the reason for this issue must be something else.

@calestyo
Copy link
Author

Here's from the 7590 AX with 8.00, in case that differs from your non-AX(?) 7590:
7590ax_8.0.txt

@kbr
Copy link
Owner

kbr commented Nov 17, 2024

You seem to have another build and hw-code (at least the latter is not surprising). Here is your build (7590 ax):

system : 259.08.00
build  : 115746
hw-code: 259
Report date: 2024-11-17 17:04:59

and here mine (7590):

system : 154.08.00
build  : 116612
hw-code: 226
Report date: 2024-11-17 17:56:38

Beside this according to my diff-tool some services in your OS 8 version are missing compared to the OS 8 version for the 7590:

WANCommonIFC1
WANDSLLinkC1
WANIPConn1
WANIPv6Firewall1

All services do refer to WAN settings. It is understandable that different devices may not support the same set of services, but for me it is suprising, that there is such a difference between 7590 and 7590 AX, which both are DSL-routers.

You may want to check this with the option -s for listing the available services of the device.
fc_OS8_20241117_services.txt

@calestyo
Copy link
Author

Differs, as well:

$ fritzconnection -e -i cerf -s

fritzconnection v1.14.0
FRITZ!Box 7590 AX at https://cerf
FRITZ!OS: 8.0

Servicenames:
                    DeviceInfo1
                    DeviceConfig1
                    Layer3Forwarding1
                    LANConfigSecurity1
                    ManagementServer1
                    Time1
                    UserInterface1
                    X_AVM-DE_Storage1
                    X_AVM-DE_WebDAVClient1
                    X_AVM-DE_UPnP1
                    X_AVM-DE_Speedtest1
                    X_AVM-DE_RemoteAccess1
                    X_AVM-DE_MyFritz1
                    X_VoIP1
                    X_AVM-DE_OnTel1
                    X_AVM-DE_Dect1
                    X_AVM-DE_TAM1
                    X_AVM-DE_AppSetup1
                    X_AVM-DE_Homeauto1
                    X_AVM-DE_Homeplug1
                    X_AVM-DE_Filelinks1
                    X_AVM-DE_Auth1
                    X_AVM-DE_HostFilter1
                    X_AVM-DE_USPController1
                    WLANConfiguration1
                    WLANConfiguration2
                    WLANConfiguration3
                    Hosts1
                    LANEthernetInterfaceConfig1
                    LANHostConfigManagement1
                    WANCommonInterfaceConfig1
                    WANDSLInterfaceConfig1
                    X_AVM-DE_WANMobileConnection1
                    WANDSLLinkConfig1
                    WANEthernetLinkConfig1
                    WANPPPConnection1
                    WANIPConnection1

Could it be that some configuration setting change the exported API?

@tobox
Copy link

tobox commented Nov 20, 2024

I am monitoring the Wifi clients on my Fritz!Box 7590, and after updating to Fritz!OS 8.00 I only get the Wifi clients for all my repeaters (non-version-8) but an empty reply for the 7590. The webinterface indicates that several Wifi clients are connected to the fritz!box. Maybe related to this?

@kbr
Copy link
Owner

kbr commented Dec 3, 2024

Seems that FritzOS 8 has breaking changes by removing some older APIs. That does not affect the fritzconnection-core reading the current API. But some some (older) parts of the library may not work any more after updating a device. That should be addressed in upcoming versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants