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

Sagemcom F@st 5655V2 Telekom support #81

Open
kobuki opened this issue Aug 8, 2021 · 12 comments
Open

Sagemcom F@st 5655V2 Telekom support #81

kobuki opened this issue Aug 8, 2021 · 12 comments

Comments

@kobuki
Copy link

kobuki commented Aug 8, 2021

Model information

Key Value
Model name F@st 5655V2
Hardware Version 1.0
Software Version SG3G10000636

Describe the bug

Doesn't seem to work, using the sample code on the main GH page. An exception is caught in the async with SagemcomClient function that only prints the text 'id'. MD5 auth method is used, SHA512 times out.

To Reproduce

Steps to reproduce the behavior:

Run the "long" sample code on https://github.com/iMicknl/python-sagemcom-api

Expected behavior

It runs and prints stuff in the router.

Screenshots

N/A

Additional context

N/A

@iMicknl
Copy link
Owner

iMicknl commented Aug 8, 2021

Could you share the full error message you get?

@kobuki
Copy link
Author

kobuki commented Aug 8, 2021

Sure, but it's not much. The output of the script attached is:

a
c
'id'

sagemcom.txt

@kobuki
Copy link
Author

kobuki commented Aug 18, 2021

@iMicknl do you think it can be fixed? How can I provide more info for you? I started looking at some payloads and by eyeballing, they look OK, but must miss some fields or maybe they're not in an arrangement that's sufficient for this FW variant.

@iMicknl
Copy link
Owner

iMicknl commented Aug 18, 2021

@kobuki are you familiar with Python yourselves? I don't have time currently to work on this, and it is especially hard to debug your router from here.

You could start with a debugger in VSCode, or just by putting print statements in the code. It would be good if you better understand the payload and where it is probably not parsing the payload correctly. The output you have shown above doesn't tell me anything unfortunately. It is weird that an exception is thrown with only the text 'id'. Best is to print the whole response there.

@kobuki
Copy link
Author

kobuki commented Aug 18, 2021

@iMicknl sure, I'll dig into a bit more, but I'd appreciate some hints, based on the stack trace and the response below if your time allows.

response after login:
[{'uid': 1, 'result': {'code': 16777238, 'description': 'Applied'}, 'xpath': 'Device', 'parameters': {'id': 1749808533, 'nonce': '2795251014'}}]

Traceback (most recent call last):
  File "sagemcom.py", line 57, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "sagemcom.py", line 27, in main
    device_info = await client.get_device_info()
  File "/usr/local/lib/python3.7/dist-packages/sagemcom_api/client.py", line 344, in get_device_info
    data = await self.get_value_by_xpath("Device/DeviceInfo")
  File "/usr/local/lib/python3.7/dist-packages/sagemcom_api/client.py", line 314, in get_value_by_xpath
    response = await self.__api_request_async([actions], False)
  File "/usr/local/lib/python3.7/dist-packages/sagemcom_api/client.py", line 204, in __api_request_async
    api_host, data="req=" + json.dumps(payload, separators=(",", ":"))
  File "/usr/local/lib/python3.7/dist-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/dist-packages/aiohttp/client.py", line 544, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/dist-packages/aiohttp/client_reqrep.py", line 890, in start
    message, payload = await self._protocol.read()  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/aiohttp/streams.py", line 604, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

So it seems the response is correct, but some other connection problem prevents the code to go further. It's either a genuine disconnect, or some other expectation in network code that fails.

@M4D1NG3R
Copy link
Contributor

M4D1NG3R commented Sep 2, 2021

@kobuki I am using a Telekom router as well.

you may need to increase the timeout try this:

from aiohttp import ClientSession, ClientTimeout
...
async def main() -> None:
    session = ClientSession(timeout=ClientTimeout(15))
    async with SagemcomClient(HOST, USERNAME, PASSWORD, ENCRYPTION_METHOD, session=session) as client:
...

@kobuki
Copy link
Author

kobuki commented Sep 2, 2021

ServerDisconnectedError is instantaneous, I don't need to wait for it to appear, so I think it's not the timeout.

@B4b4sh
Copy link

B4b4sh commented Jan 22, 2022

I have the same problem with the official Proximus BBox3. Only a text 'id' is printed. Did you solved it ?

@skyjet18
Copy link

skyjet18 commented Dec 4, 2023

The reason for "aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected" is because you are sending requests too fast. Just put 0.5s between requests and the problem will be solved.

@kobuki
Copy link
Author

kobuki commented Dec 4, 2023

In my case it's on the first call, so no subsequent ones to repeat too fast.

@skyjet18
Copy link

skyjet18 commented Dec 4, 2023

There are two independed problems here: The first one is that I wrote - when you send requests too fast, then it will end on ServerDisconnectedError exception. When this happens your session will stay logged on server and the second login attempt will end with 'id' Exception (and you need to wait couple of minutes in order to session expire). The reason is, that telecom firmware doesn't return XMO_* error descriptions but English translations. Just replace XMO_REQUEST_ACTION_ERR in const.py with 'Action error' and you will see the real login error reason.
Try the example shown in readme, but add 'await asyncio.sleep(1)' before every client.* call. It will work. Tested on Sagemcom from Telecom Slovakia.

@baranyaib90
Copy link

Sleeping between requests really helped in my case. Thank you very much!

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

6 participants