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

raise ConnectionError() - Speedport3 #3

Open
foxmulder4223 opened this issue May 13, 2024 · 1 comment
Open

raise ConnectionError() - Speedport3 #3

foxmulder4223 opened this issue May 13, 2024 · 1 comment

Comments

@foxmulder4223
Copy link

foxmulder4223 commented May 13, 2024

Hey Andre,

I stumbled accross your api and I loved it. It basically does everything I want to do, BUT I have a Speedport 3 in place. Whenever I try to run your code it raises a connection error as seen below:

Traceback (most recent call last):
  File "/Users/USERNAME/Library/CloudStorage/OneDrive-TUI/Skripte/Python Skripte/network.py", line 23, in <module>
    devices = asyncio.run(Speedport().devices)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/site-packages/speedport/speedport.py", line 81, in devices
    data = await self.api.get_devices()
                 ^^^^^^^^
  File "/Users/USERNAME/.pyenv/versions/3.11.6/lib/python3.11/site-packages/speedport/speedport.py", line 77, in api
    raise ConnectionError()

Here is why I find this really interesting. When I try to connect to the router via script a (synchronously) the script says

Login successful!
/Users/USERNAME/Library/CloudStorage/OneDrive-TUI/Skripte/Python Skripte/network.py:16: RuntimeWarning: coroutine 'Speedport.login' was never awaited

in script b (asynchronously) I receive the already posted connection error. Is there more to it that I don't see or is it "just" because of the speedport 3? I have to admit network stuff (specifically web and javascript) are not my strongsuit.

script a

from speedport import Speedport

def login_to_router(url, password):
    speedport = Speedport(url)
    
    # Login to the router
    login_status = speedport.login(password)
    
    if login_status:
        print("Login successful!")
    else:
        print("Login failed!")

url = 'http://192.168.2.1' 
password = 'PASSWORD' 
login_to_router(url, password)

script b

from speedport import Speedport
import asyncio

async def login_to_router(url, password):
    try:
        speedport = Speedport(url)
        
        # Try to login to the router
        login_status = await speedport.login(password)
        
        if login_status:
            print("Login successful!")
        else:
            print("Login failed!")
    except Exception as e:
        print(f"Failed to connect to the router. Error: {e}")

url = 'http://192.168.2.1'  # replace with your router's URL
password = 'PASSWORD'  # replace with your password
asyncio.run(login_to_router(url, password))
@foxmulder4223
Copy link
Author

Hey @Andre0512
Now I have a speedport smart 4, and still the same error..

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

1 participant