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

UPnP Error #185

Open
Emporea opened this issue May 7, 2023 · 3 comments
Open

UPnP Error #185

Emporea opened this issue May 7, 2023 · 3 comments

Comments

@Emporea
Copy link

Emporea commented May 7, 2023

Hey. I am struggling with this error. I already read some issues in this repo and some other forums but i cant really figure out how to solve it.

Basically I want an easy on / off switch for port forwarding in my fritzbox.

Thus I did this:

fc = FritzConnection(
    address=FRITZBOX_IP, user=FRITZBOX_USERNAME, password=FRITZBOX_PASSWORD
)
fc.call_action(
    ACTION,
    'AddPortMapping',
    NewRemoteHost='0.0.0.0',
    NewExternalPort=21,
    NewProtocol="TCP",
    NewInternalPort=21,
    NewInternalClient=SERVER_IP,
    NewEnabled=True,
    NewPortMappingDescription='Port Mapping ',
    NewLeaseDuration=0,)

respectivly this to delete it:

fc.call_action(
        ACTION,
        'DeletePortMapping',
        NewExternalPort=21,
        NewProtocol="TCP")

But all I get are these errors.. i had 401,402 and 403 so far, but this UPnPError pops up everytime...

Traceback (most recent call last):
  File "/home/coder/project/Batch_Bash/fritzPorts", line 35, in <module>
    fc.call_action(
  File "/usr/local/lib/python3.9/dist-packages/fritzconnection/core/fritzconnection.py", line 441, in call_action
    return self.soaper.execute(service, action_name, arguments)
  File "/usr/local/lib/python3.9/dist-packages/fritzconnection/core/soaper.py", line 286, in execute
    return handle_response(response)
  File "/usr/local/lib/python3.9/dist-packages/fritzconnection/core/soaper.py", line 268, in handle_response
    raise_fritzconnection_error(response)
  File "/usr/local/lib/python3.9/dist-packages/fritzconnection/core/soaper.py", line 191, in raise_fritzconnection_error
    raise exception(message)
fritzconnection.core.exceptions.FritzConnectionException: UPnPError: 
errorCode: 403
errorDescription: Not available Action

What can I do?
Or is there a much easier way to activate / disable port mappings without deleting them everytime?
Thanks.

@kbr
Copy link
Owner

kbr commented May 7, 2023

I have to guess what happens here, as this error is forwarded from the router. The message also is a bit misleading: the action is known, otherwise a FritzActionError (401) should get raised. So I suppose the user has not the proper rights to execute the DeletePortMapping action.

(btw. the ACTION argument is the service-name (WANIPConn1), not the action – the action is DeletePortMapping)

@Emporea
Copy link
Author

Emporea commented May 7, 2023

Thank you for your reply. Yes, I know that the ACTION variable was not really the best choice. I have corrected it.
What is the difference between WANIPConn1 and WANIPConnection1? Both are valid services and have multiple actions for port mapping. Neither works though.

I am struggling to find the reason.

  • I have added a new fritzbox user with all permissions.
  • I made sure to enable tr-064
  • I made sure the password is correct
  • A few other things

Do I need to enable other options in my FritzBox (7.50) such as UPNP or other options for this to work?

What is a good service + action to check if a login with the given username and password was successful and which rights or options are missing?

Thanks for your help.

@kbr
Copy link
Owner

kbr commented May 7, 2023

What is the difference between WANIPConn1 and WANIPConnection1? Both are valid services and have multiple actions for port mapping. Neither works though.

I suppose one (WANIPConn1) is the UPnP- and the other (WANIPConnection1) the TR-064 interface and both seems to support a common subset of settings.

I am struggling to find the reason.

  • I have added a new fritzbox user with all permissions.
  • I made sure to enable tr-064
  • I made sure the password is correct
  • A few other things

Do I need to enable other options in my FritzBox (7.50) such as UPNP or other options for this to work?

If setting a checkmark to "FRITZ!Box Settings – Users with this right can view and edit all FRITZ!Box settings." does not work, I have also no idea whether there are more hidden settings. The AVM documentation about TR-064 remote access notes that "There are some actions which are not completely supported for the remote access". I don't know whether this is also true for PortMappings and LAN access (may be for security reasons).

What is a good service + action to check if a login with the given username and password was successful and which rights or options are missing?

For my knowledge there is none. Some actions will just not work.

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

2 participants