Salamek / huawei-lte-api-ts

API For huawei LAN/WAN LTE Modems written in TypeScript
GNU Lesser General Public License v3.0
48 stars 19 forks source link

Getting "125003: Unknown" for net.setNetMode #23

Open Pezhvak opened 2 years ago

Pezhvak commented 2 years ago

Hi, Thank you for creating this repository, I'm trying to change notMode with the following code:

await con.postSet('net/net-mode', {
      'NetworkMode': '03',
      'NetworkBand': '2000004400000',
      'LTEBand': '7FFFFFFFFFFFFFFF',
  });

result is: "Error: 125003: Unknown"

The same code in python works:

connection.post_set(endpoint='net/net-mode', data={
    'NetworkMode': '03',
    'NetworkBand': '2000004400000',
    'LTEBand': '7FFFFFFFFFFFFFFF',
})

result is: "OK"

The same is happening with built-in methods:

await net.setNetMode('7FFFFFFFFFFFFFFF', '2000004400000', '02');
await net.setNetMode('7FFFFFFFFFFFFFFF', '2000004400000', '03');

result is: "Error: 125003: Unknown"

net.set_net_mode('7FFFFFFFFFFFFFFF', '2000004400000', '02')
net.set_net_mode('7FFFFFFFFFFFFFFF', '2000004400000', '03')

result is: "OK".

Pezhvak commented 2 years ago

BTW, the same is happening when I'm trying to call device.reboot().

Salamek commented 2 years ago

Hi, i wont have time to check this for next few days (maybe a week) so if you need to resolve this fast, you may try to debug this your self.

1) print() || console.log() build XML request in Python || TS version and compare if there is any difference 2) Use wireshark to sniff HTTP request that is made to your router/modem in Python || TS version and compare 3) ... 4) Profit

Pezhvak commented 2 years ago

@Salamek I've tried what you said and this is the result:

Trying to monitor traffic, i had to use proxy opened for the dongle (since they are hosted on another machine), surprisingly setNetMode worked fine with proxy, however when i tried to use the same script on the machine which is hosting those dongles it fails. (note that i have multiple dongles connected on the host). i don't understand how can node get confused considering we are providing modem IP to connection class hence using it in requests that is being sent, and this issue doesn't occur in python flavor.

Requests are identical between python and nodejs (python sends multiple requests one after the other before logging in to (/state-login), which i don't know if it has any effect, since all responses are equal (including response headers). this might be a problem on python side, however, to me it seems there is something wrong in axios, with that said, even trying to control the dongle over proxy, it fails to log the user out. (requests are the same again). and the error is: "125003" (which i found the issue and fixed in #24)

Here is a screenshot of requests (might be helpful to see): Screen Shot 2022-02-23 at 3 28 13 PM Note: the selected portion of the requests are sent using nodejs, and unselected ones is sent by python. ( you can see python sends multiple requests to /api/user/state-login before logging in). i didn't include headers and responses of the requests because they are identical except session and __RequestVerificationToken as it should be.

Since i don't have access to the machine which is hosting those dongles i cannot monitor traffic without proxy to find out why it doesn't work directly. (This problem is only with POST requests and absent if i use a proxy to connect to the dongle, GET requests like device.signal(), device.information() are working correctly without a proxy as far as i could test).

I think i will have to keep using a proxy to communicate with the dongles until you find time to look at it.

Let me know if i could help. Thanks.