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

xiaomi vaccum cleaner not responding #92

Closed
btrial opened this issue Oct 18, 2017 · 49 comments
Closed

xiaomi vaccum cleaner not responding #92

btrial opened this issue Oct 18, 2017 · 49 comments

Comments

@btrial
Copy link

btrial commented Oct 18, 2017

Hi,

I am using your mirobo library to start and stop my xiaomi mija vacuum cleaner. It works great, except the case when the vacuum is not being called for longer period of time (day/two).

Then when I try to start the cleaner using your library I get following errors.
If I try about 3 times in a row, it start to work again, and works fine.
It looks like the vacuum goes to sleep maybe ?

Executing command: sudo mirobo --ip 192.168.1.25 --token 33795a47547535596d6a526e3563434c start
Response from command execution: 1
ERROR:mirobo.device:Unable to discover a device at address 192.168.1.25
Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 11, in
sys.exit(cli())
File "/usr/lib/python3/dist-packages/click/core.py", line 716, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/mirobo/vacuum_cli.py", line 152, in start
click.echo("Starting cleaning: %s" % vac.start())
File "/usr/local/lib/python3.5/dist-packages/mirobo/vacuum.py", line 27, in start
return self.send("app_start")
File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 121, in send
self.do_discover()
File "/usr/local/lib/python3.5/dist-packages/mirobo/device.py", line 73, in do_discover
raise DeviceException("Unable to discover the device %s" % self.ip)
mirobo.device.DeviceException: Unable to discover the device 192.168.1.25

@rytilahti
Copy link
Owner

Unfortunately I have no solution for this problem, but let's keep it open for now.

@MaxRei-dev
Copy link

MaxRei-dev commented Oct 24, 2017

same here:

`DEBUG:miio.protocol:Unable to decrypt, returning raw bytes.
DEBUG:miio.device:Got a response: Container:
data = Container:
data = (total 0)
length = 0
value = (total 0)
offset2 = 32
offset1 = 32
header = Container:
data = !1\x00 \x00\x00\x00\x00\x03L\xf1+Y\xef(\xdf (total 16)
length = 16
value = Container:
length = 32
unknown = 0
devtype = 844
serial = 61739
ts = 2017-10-24 11:49:51
offset2 = 16
offset1 = 0
checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered 844 61739 with ts: 2017-10-24 11:49:51, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.112:54321 >>: {'method': 'get_status', 'id': 9461}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Unable to discover a device at address 192.168.1.112
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 200, in send
data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/mirobo", line 11, in
sys.exit(cli())
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
return Command.invoke(self, ctx)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 86, in cli
ctx.invoke(status)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 116, in status
res = vac.status()
File "/usr/local/lib/python3.4/dist-packages/miio/vacuum.py", line 97, in status
return VacuumStatus(self.send("get_status")[0])
File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 222, in send
return self.send(command, parameters, retry_count - 1)
File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 165, in send
self.do_discover()
File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 118, in do_discover
raise DeviceException("Unable to discover the device %s" % self.ip)
miio.device.DeviceException: Unable to discover the device 192.168.1.112`

@rytilahti
Copy link
Owner

Is this with 0.3.0 or with an earlier release? If with an earlier one, could you try and update (we have changed the handshake only to send a single discovery packet, as sending multiple caused some sort of flood protection on some devices)?

@btrial
Copy link
Author

btrial commented Oct 25, 2017

Will check later today when come back home. Can you please remind me how can i check the version ? mirobo --help or mirobo --version ?

@MaxRei-dev
Copy link

mirobo --version to check version. but i'am on 0.3.0 and have a similar error.

@btrial
Copy link
Author

btrial commented Oct 25, 2017

I have version 0.2.0, so updated just right now to version 0.3.0, and tried it out.
Same error on first try. On second it went fine.

@bachya
Copy link

bachya commented Nov 5, 2017

Same here. Using mirobo version 0.3.1. I reset my vacuum, did the discovery:

$ mirobo discover --handshake 1

...and got back a good token:

INFO:miio.device:Sending discovery to <broadcast> with timeout of 5s..
INFO:miio.device:  IP 192.168.8.1: 986 - token: b'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
INFO:miio.device:Discovery done

However, when I try to use this token (with the correct IP):

mirobo --ip 192.168.1.130 --token b'xxxxxxxxxxxxxxxxxxxxxxxxxxxx

...I get the same stack trace:

ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
ERROR:miio.device:Unable to discover a device at address 192.168.1.130
Traceback (most recent call last):
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/vacuum_cli.py", line 86, in cli
    ctx.invoke(status)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/vacuum_cli.py", line 116, in status
    res = vac.status()
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/vacuum.py", line 99, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 165, in send
    self.do_discover()
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 118, in do_discover
    raise DeviceException("Unable to discover the device %s" % self.ip)
miio.device.DeviceException: Unable to discover the device 192.168.1.130

Incidentally, sometimes, I'll get this response instead:

ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 1
ERROR:miio.device:Got error when receiving: timed out
Traceback (most recent call last):
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 200, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 200, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 200, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 200, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/vacuum_cli.py", line 86, in cli
    ctx.invoke(status)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/vacuum_cli.py", line 116, in status
    res = vac.status()
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/vacuum.py", line 99, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 222, in send
    return self.send(command, parameters, retry_count - 1)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 222, in send
    return self.send(command, parameters, retry_count - 1)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 222, in send
    return self.send(command, parameters, retry_count - 1)
  File "/Users/abach/.local/share/virtualenvs/miio-Q_DY263b/lib/python3.6/site-packages/miio/device.py", line 223, in send
    raise DeviceException from ex
miio.device.DeviceException

@bachya
Copy link

bachya commented Nov 5, 2017

Just tried running the same command in debug mode and got this:

INFO:miio.vacuum_cli:Debug mode active
ERROR:miio.vacuum_cli:Unable to read the stored msgid: [Errno 2] No such file or directory: '/tmp/python-mirobo.seq'
DEBUG:miio.vacuum_cli:Connecting to 192.168.1.130 with token 5a653170446642364f4c6d37384d7761
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes.
DEBUG:miio.device:Got a response: Container:
    data = Container:
        data =  (total 0)
        value =  (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        data = !1\x00 \x00\x00\x00\x00\x03\xda\xbe\xa4Y\xffTO (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = 986
            serial = 48804
            ts = 2017-11-05 18:11:27
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered 986 48804 with ts: 2017-11-05 18:11:27, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.1.130:54321 >>: {'id': 1, 'method': 'miIO.info', 'params': []}
ERROR:miio.device:Got error when receiving: timed out

The DEBUG:miio.protocol:Unable to decrypt, returning raw bytes. line is interesting; is this supposed to happen, or does this mean my token is somehow incorrect?

@bachya
Copy link

bachya commented Nov 6, 2017

Sounds like these folks are having a similar issue: aholstenson/miio#59

@bachya
Copy link

bachya commented Nov 6, 2017

Got my case figured it. At some point, it looks like the token changed on me; rediscovered it from an iOS backup and everything started working.

@MatsKarlsson
Copy link

@bachya Had the same problems:
disconnected from wifi, extracted token, connected vacuum to wifi. Then when trying to use mirobo with latest token it failed like for you: 'no such file or directory ...' and 3 retries.

Then extracted token from android-apk/sqlite-db, it was a different token, so tried that with mirobo and it worked immediately.

@sumnerboy12
Copy link

I just upgraded to v0.3.1 and am still seeing intermittent connection problems (I wonder if the robot is shutting down wifi periodically?).

Not sure if what I am seeing is exactly the same as the OP, but it definitely works some of the time, and fails to connect other times.

When a status request fails I am seeing this;

iot@iot01:~$ mirobo --ip 192.168.40.40 --token XXXXX -d
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'manual_seq': 0, 'seq': 345}
DEBUG:miio.vacuum_cli:Connecting to 192.168.40.40 with token XXXXX
ERROR:miio.device:Unable to discover a device at address 192.168.40.40
Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 86, in cli
    ctx.invoke(status)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 116, in status
    res = vac.status()
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum.py", line 99, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 165, in send
    self.do_discover()
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 118, in do_discover
    raise DeviceException("Unable to discover the device %s" % self.ip)
miio.device.DeviceException: Unable to discover the device 192.168.40.40

It will fail like this for 5-10 times and then all of a sudden work;

iot@iot01:~$ mirobo --ip 192.168.40.40 --token XXXXX -d
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'manual_seq': 0, 'seq': 345}
DEBUG:miio.vacuum_cli:Connecting to 192.168.40.40 with token XXXXX
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes.
DEBUG:miio.device:Got a response: Container:
    data = Container:
        value =  (total 0)
        data =  (total 0)
        offset1 = 32
        offset2 = 32
        length = 0
    header = Container:
        value = Container:
            length = 32
            unknown = 0
            devtype = 987
            serial = 40604
            ts = 1970-01-01 18:55:02
        data = !1\x00 \x00\x00\x00\x00\x03\xdb\x9e\x9c\x00\x01\n\x06 (total 16)
        offset1 = 0
        offset2 = 16
        length = 16
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered 987 40604 with ts: 1970-01-01 18:55:02, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.40.40:54321 >>: {'method': 'get_status', 'id': 346}
DEBUG:miio.device:192.168.40.40:54321 (ts: 1970-01-01 18:55:02, id: 346) << {'result': [{'in_cleaning': 0, 'clean_area': 104695000, 'dnd_enabled': 1, 'msg_ver': 5, 'msg_seq': 29, 'fan_power': 90, 'battery': 100, 'map_present': 0, 'clean_time': 6774, 'state': 8, 'error_code': 0}], 'id': 346}
State: Charging
Battery: 100 %
Fanspeed: 90 %
Cleaning since: 1:52:54
Cleaned area: 104.695 m²
DEBUG:miio.vacuum_cli:Writing {'manual_seq': 0, 'seq': 346} to /tmp/python-mirobo.seq

@rytilahti
Copy link
Owner

rytilahti commented Nov 20, 2017

@sumnerboy12 How often are you requesting information from the vacuum? Maybe it has some sort of protection mechanism when too many requests are made consecutively? :-)

@MatsKarlsson that's a good catch, that the token extracted from the device will not work (anymore, if it ever did with newer FWs) at all!

@sumnerboy12
Copy link

I did wonder that, but I have found that making a request after > 24hrs still results in this error (sometimes). When it starts working I can fire off requests quite rapidly (1 per sec) and they all come back. Then after a while it seizes up and remains that way for a number of minutes.

@rytilahti
Copy link
Owner

Ok, good to know. I'm not sure how to start debugging that though, the device remains connected to the network all the time though, I suppose?

@sumnerboy12
Copy link

The device should be connected - it is sitting in its dock under my desk and there is a Unifi UAP directly above it. But I am wondering if it periodically disconnects to save battery or something? I have noticed that while it is running it re-connects (I have an alert whenever my DHCP server assigns an IP address) quite frequently, sometimes 4-5 times during a clean.

@sumnerboy12
Copy link

UPDATE: still exhibiting this behaviour with v0.32.

@mariuszluciow
Copy link

Does anybody managed to get this working with the latest firmware, 3.3.9_003077 ?

The library correctly exchanges handshake, and fails with timeout when trying to send method. Token is extracted from android app, I've already tried to reset the device and send those with new token, but no luck so far.

DEBUG:miio.device:192.168.0.17:54321 >>: {'method': 'get_status', 'id': 101}
ERROR:miio.device:Got error when receiving: timed out

@rytilahti
Copy link
Owner

@mariuszluciow I have been running it all the time with that firmware without problems, also using a token extracted from the android app.

@sumnerboy12 unfortunately I have no idea with regards to its network behavior, I have not been keeping track on that. Is your robot allowed to communicate with the xiaomi servers or are you keeping it locked away from the internet like I do?

@sumnerboy12
Copy link

sumnerboy12 commented Dec 10, 2017 via email

@mariuszluciow
Copy link

@rytilahti I've installed the https://github.com/ioBroker/ioBroker.mihome-vacuum - surprisingly the iobroker is able to talk with my vacuum. I will take a look later what's the difference between this lib and the iobroker plugin.

@sumnerboy12
Copy link

Updated error message after upgrading to latest version;

iot@iot01:~$ mirobo --ip 192.168.40.40 --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 1
ERROR:miio.device:Got error when receiving: timed out
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 86, in cli
    ctx.invoke(status)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 116, in status
    res = vac.status()
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum.py", line 107, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 259, in send
    raise DeviceException from ex
miio.device.DeviceException

@sumnerboy12
Copy link

So it looks like the robot just stops responding periodically. Doesn't seem to matter if it is on charge, or in use. It will work for a few minutes and then stop for a few minutes.

@sumnerboy12
Copy link

And the same log, with debug enabled (in case there is something else in there that might help explain);

iot@iot01:~$ mirobo --ip 192.168.40.40 --token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --debug
INFO:miio.vacuum_cli:Debug mode active
DEBUG:miio.vacuum_cli:Read stored sequence ids: {'manual_seq': 0, 'seq': 398}
DEBUG:miio.vacuum_cli:Connecting to 192.168.40.40 with token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        offset1 = 32
        length = 0
        offset2 = 32
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xdb\x9e\x9c\x00\x01\x01\xee (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 40604
            ts = 1970-01-01 18:20:30
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered default 40604 with ts: 1970-01-01 18:20:30, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.40.40:54321 >>: {'method': 'get_status', 'id': 399}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 3
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        offset1 = 32
        length = 0
        offset2 = 32
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xdb\x9e\x9c\x00\x01\x01\xf3 (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 40604
            ts = 1970-01-01 18:20:35
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered default 40604 with ts: 1970-01-01 18:20:35, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.40.40:54321 >>: {'method': 'get_status', 'id': 500}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 2
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        offset1 = 32
        length = 0
        offset2 = 32
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xdb\x9e\x9c\x00\x01\x01\xf8 (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 40604
            ts = 1970-01-01 18:20:40
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered default 40604 with ts: 1970-01-01 18:20:40, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.40.40:54321 >>: {'method': 'get_status', 'id': 601}
ERROR:miio.device:Got error when receiving: timed out
WARNING:miio.device:Retrying with incremented id, retries left: 1
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
    data = Container:
        offset1 = 32
        length = 0
        offset2 = 32
        data =  (total 0)
        value =  (total 0)
    header = Container:
        offset1 = 0
        length = 16
        offset2 = 16
        data = !1\x00 \x00\x00\x00\x00\x03\xdb\x9e\x9c\x00\x01\x01\xfe (total 16)
        value = Container:
            length = 32
            unknown = 0
            devtype = default (total 7)
            serial = 40604
            ts = 1970-01-01 18:20:46
    checksum = \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff (total 16)
DEBUG:miio.device:Discovered default 40604 with ts: 1970-01-01 18:20:46, token: b'ffffffffffffffffffffffffffffffff'
DEBUG:miio.device:192.168.40.40:54321 >>: {'method': 'get_status', 'id': 702}
ERROR:miio.device:Got error when receiving: timed out
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 236, in send
    data, addr = s.recvfrom(1024)
socket.timeout: timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/mirobo", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 86, in cli
    ctx.invoke(status)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum_cli.py", line 116, in status
    res = vac.status()
  File "/usr/local/lib/python3.4/dist-packages/miio/vacuum.py", line 107, in status
    return VacuumStatus(self.send("get_status")[0])
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 258, in send
    return self.send(command, parameters, retry_count - 1)
  File "/usr/local/lib/python3.4/dist-packages/miio/device.py", line 259, in send
    raise DeviceException from ex
miio.device.DeviceException

@sumnerboy12
Copy link

Sorry to spam this issue, but just tried again and got the same error that I posted previously (26 days ago), which is different to the one I just posted above. Very odd.

@zhkufish
Copy link

Can't reach my mirobo #145 when I see this. I Downgrade to construct==2.8.16.. But I have new error..
DEBUG:miio.protocol:Unable to decrypt, returning raw bytes: b''
DEBUG:miio.device:Got a response: Container:
data = Container:
length = 0
data = (total 0)
offset1 = 32
offset2 = 32
value = (total 0)
header = Container:
length = 16
data = !1\x00 \x00\x00\x00\x00\x03\xed\xff\xfa\x00\x00.= (total 16)
offset1 = 0
offset2 = 16
value = Container:
length = 32
unknown = 0
devtype = 1005
serial = 65530
ts = 1970-01-01 03:17:17
checksum = \x14\xce\x8a\x87\x0e\xe1\xbd\xcb)\xd5\xe3\xc4\xef\xc3\xd0\xa9 (total 16)
DEBUG:miio.device:Discovered 1005 65530 with ts: 1970-01-01 03:17:17, token: b'14ce8a870ee1bdcb29d5e3c4efc3d0a9'
DEBUG:miio.device:192.168.31.124:54321 >>: {'id': 2, 'params': ['power', 'temperature'], 'method': 'get_prop'}
DEBUG:miio.device:192.168.31.124:54321 (ts: 1970-01-01 03:17:18, id: 2) << {'id': 2, 'result': ['off', 37]}
Power: off
Temperature: 37
Traceback (most recent call last):
File "/srv/homeassistant/homeassistant_venv/bin/miplug", line 11, in
sys.exit(cli())
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/core.py", line 722, in call
return self.main(*args, **kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/miio/plug_cli.py", line 81, in status
click.echo("Load (W): %s" % res.load_power)
AttributeError: 'PlugStatus' object has no attribute 'load_power'

@mapl
Copy link

mapl commented Jan 17, 2018

Hi guys,

I've faced the same timeout issue. It turned out that my token had changed.

I did a full factory reset (home+reset button), connected to the mi robot wifi, ran a discovery and got back a token. That token worked.

However, when I setup (no firmware update) my mi robot in the MI home app (iOS), discovery didn't work anymore using the previously obtained token... That made me curious what might have changed so tried the android root method (https://github.com/jghaanstra/com.xiaomi-miio/blob/master/docs/obtain_token_mirobot_new.md) and look! another token was displayed! I gave it a try and it worked again.

@rytilahti
Copy link
Owner

@zhkufish that is another issue, if the problem still exist please open a separate issue for that.

@mapl when you set it up in the mobile app, the robot will be provisioned with a new token, thereby making the old one invalid. It should also be noted that the newer firmware versions do not allow token extraction at all, but one has to resort to extracting it from a backup. The procedure is described in the documentation: https://python-miio.readthedocs.io/en/latest/discovery.html#tokens-from-backups .

@mapl
Copy link

mapl commented Jan 17, 2018

It wasn't clear enough to me as I assumed the token will never change. Once you have the token you're ready to go. Thanks for pointing that out

@rytilahti
Copy link
Owner

Yeah, I think it would be nice to have a sort of FAQ or most common problems and possible solutions to them in the documentation. So if anyone is interested in writing some documentation, that could be something to contribute to :-)

@sumnerboy12
Copy link

UPDATE: I moved my vacuum to an internet-accessible VLAN and now I can continuously connect with no issues. I am polling the vacuum every 10s and it seems to be rock solid. I re-tried moving back to my isolated VLAN (for IOT devices) and had the same connection issues as before.

I am guessing the vacuum is trying to phone-home and is blocking the connection handler/port/something while this attempt times out. And therefore I can only get through locally if I happen to attempt a connection outside of this timeout period.

Is anyone else running their vacuum in an isolated VLAN?

@rytilahti
Copy link
Owner

@sumnerboy12 I'm running mine in an isolated system, although I let it do DNS requests but do not let it do anything else. Anyway, your findings seem to be similar what I just experienced while reading the logs directly out from the vacuum; when mirobo status timed out, I saw this piece of log (/mnt/data/rockrobo/rrlog/miio.log):

[20180211 21:24:54] [DEBUG] server_conn_retry, dump server list udp_init.
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.224, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.112, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.111, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.245, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.113, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.114, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.246, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.247, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.248, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.249, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 124.251.57.10, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 124.251.57.11, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 124.251.57.12, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.244, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.225, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.2, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.241, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 120.92.96.242, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.115, port: 8053
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.223, port: 8053
[20180211 21:24:54] [DEBUG] server_conn_retry, dump server list tcp_init.
[20180211 21:24:54] [DEBUG] dump_server_list, server list NULL.
[20180211 21:24:54] [DEBUG] server_conn_retry, dump server list udp.
[20180211 21:24:54] [DEBUG] UDP server, ip: 42.62.48.224, port: 8053
[20180211 21:24:54] [DEBUG] server_conn_retry, dump server list tcp.
[20180211 21:24:54] [DEBUG] dump_server_list, server list NULL.
[20180211 21:24:55] [WARNING] error in trying to connect socket: Connection refused
[20180211 21:24:55] [WARNING] error in trying to connect socket: Connection refused
[20180211 21:24:55] [WARNING] error in trying to connect socket: Connection refused
[20180211 21:24:55] [WARNING] error in trying to connect socket: Connection refused
[20180211 21:24:55] [WARNING] error in trying to connect socket: Connection refused
[20180211 21:24:55] [WARNING] error in trying to connect socket: Connection refused
[20180211 21:24:55] [INFO] Retry (6/-1), host ip: 42.62.48.224, port: 8053
[20180211 21:24:55] [INFO] OT client fd: 16
[20180211 21:24:55] [INFO] report_synctime
[20180211 21:24:55] [WARNING] POLLNVAL | POLLHUP | POLLERR fd: pollfds[8]: 16, revents: 0x00000008
[20180211 21:24:55] [DEBUG] OT server: 42.62.48.224, port: 8053 not response, close (socket 16)
[20180211 21:24:57] [INFO] OT protocol diagrams come...
[20180211 21:24:57] [INFO] Fill my DID
[20180211 21:24:57] [INFO] Fill my TIMESTAMP

afterwards it will seem to do some sort of initialization routine:

[20180211 21:24:59] [INFO] Set data dir to: /mnt/data/miio/
[20180211 21:24:59] [INFO] Set TCP host to "ott.io.mi.com"
[20180211 21:24:59] [INFO] Set UDP host to "ot.io.mi.com"
[20180211 21:24:59] [INFO] OT smart conn sockfd: 8
[20180211 21:24:59] [INFO] OT agent listen fd: 10
[20180211 21:24:59] [INFO] BT conn listen fd: 11
[20180211 21:24:59] [INFO] Timer fd: 12, interval: 5000 ms
[20180211 21:24:59] [INFO] Sync timer fd: 13, interval: 0 ms
[20180211 21:24:59] [INFO] ACK timer fd: 14, timeout: 0 ms
[20180211 21:24:59] [INFO] pollfds[0]: 8
[20180211 21:24:59] [INFO] pollfds[1]: 10
[20180211 21:24:59] [INFO] pollfds[2]: 11
[20180211 21:24:59] [INFO] pollfds[3]: 12
[20180211 21:24:59] [INFO] pollfds[4]: 13
[20180211 21:24:59] [INFO] pollfds[5]: 14
{"method":"_internal.helper_ready"}
[20180211 21:24:59] [INFO] OT agent listen accept sockfd: 15
[20180211 21:24:59] [INFO] ot_agent_recv_handler_one
[20180211 21:24:59] [DEBUG]  fd: 15, length: 35 bytes
[20180211 21:24:59] [DEBUG] Got _internal.helper_ready.
[20180211 21:24:59] [INFO] OT agent listen accept sockfd: 15
[20180211 21:24:59] [INFO] ot_agent_recv_handler_one
[20180211 21:24:59] [DEBUG]  fd: 15, length: 28 bytes
[20180211 21:24:59] [DEBUG] Got _internal.hello.
[20180211 21:24:59] [INFO] STATE: (0)
[20180211 21:24:59] [DEBUG] check_device_info:1268, didkeyreq_timestamp: 0, didkeyreq_interval: 30.
[20180211 21:24:59] [DEBUG] cmd_internal_request_dinfo
[20180211 21:24:59] [INFO] OT agent internalfd closed: 15
Got _internal.request_dinfo

@sumnerboy12
Copy link

Your tip for allowing DNS requests seems to have worked (initially at least). I moved the vacuum back to my IOT VLAN (with no internet access) but enabled outgoing DNS requests.

I can now reliably access the vacuum using mirobo. Thanks very much for the tip!!

@sumnerboy12
Copy link

Argh...spoke too soon. After half an hour or so of good connection it has since been broken again. Looking in the logs it seems to connect OK for about 60s and then I get 6 mins (almost to the second) of dead time.

I am polling the device every 10s to retrieve the state and publish to MQTT.

@rytilahti
Copy link
Owner

Ah, sorry if I misled you, I just mentioned allowing DNS requests as it is in my current setup. I'm getting also those timeouts now and then, and I think the reason is indeed that the vacuum cannot communicate with their servers. If someone here is having this problem even when having the vacuum connected to the cloud, there might be also other problems there in the protocol implementation.

@sumnerboy12
Copy link

No need to apologise! I am prepared to try anything at the moment :). My timeouts are definitely not occasional, they seem to be pretty consistent - around 60s ok, then 6 mins (to the second) timing out, repeat.

For now I have just given the vacuum full internet access from my IOT VLAN thru the firewall. I will keep watching this thread with interest.

BTW - thank you for the fantastic library!!

@beatmag
Copy link

beatmag commented Feb 12, 2018

I’m having the exact same problem. I’ve placed the vacuum gen 2 onto network that doesn’t have internet. Mirobo works sometimes and sometimes not.

HASS mostly has a lot of failed messages but once in a while it can get a successfully api request in.

So allowing DNS doesn’t work either?

@sumnerboy12
Copy link

Didn't seem to for me, no. The robot must be blocking the API listening port while it tries to connect to the Xiaomi servers, which seems to take 6 mins to timeout on my robot. It then re-tries about a minute later, meaning the majority of the time it is blocking access from openHAB/HA.

@rytilahti
Copy link
Owner

What kind of isolation you have in your network? Are you sending ICMP unreachables and TCP resets back on connection attempts? If not, maybe that could help to speed up the timeouting, considering the robot runs a linux kernel. And you're welcome, it's nice to hear that people find it useful :-)

@sumnerboy12
Copy link

Unfortunately networking is not my area of expertise. I am running a Unifi USG with pretty simple firewall rules to isolate the IOT VLAN and that is about it. I will do some reading to see if I can implement some additional rules as you describe, to try and shorten the timeout.

@sumnerboy12
Copy link

@rytilahti you are a genius. I did some reading and up-skilled a little on firewall configs. As a result I changed my IOT VLAN outgoing firewall rule from drop to reject and now the vacuum is not experiencing the 6 min time outs. I left it running overnight and only noticed the occasional (quick) timeout. Many many thanks for your helpful suggestion!

@rytilahti
Copy link
Owner

Glad to hear you got it working! It won't indeed fix it completely, but it is not so terrible (and I think usually the second try will go through like always?). Maybe that's something to add to "Common problems"/FAQ section of the docs 👍

@sumnerboy12
Copy link

Yep, might be worthwhile, as I can imagine there are quite a few users that wish their vacuum to be on an isolated VLAN, rather than broadcasting their house floor plans to some remote servers in China!

@rytilahti
Copy link
Owner

PRs are welcome! ;-)

@beatmag
Copy link

beatmag commented Feb 15, 2018

Is it as simple as telling iptables to reject with tcp reset and icmp unreachable for any forwards???

I tried. But I suspect I need to do the same for DNS requests. Since DNS request isn’t a forward.

Could you show us the iptable commands?

@arekbulski
Copy link
Contributor

Heeey, its NOT construct related! Everyone upvote the fanfare emote!

@nrepian
Copy link

nrepian commented Feb 17, 2018

I'm having the same problem (running in an isolated VLAN), but unfortunately I don't have the option to "reject", only "block". Do you have any other ideas that may work around this?

@beatmag
Copy link

beatmag commented Feb 17, 2018

Hi all.
So I made the changes to reject tcp reset for tcp and Icmp unreachabke for udp.

It’s working much better now!!!!

Pretty much had to block all forwards with reject and then block dns request since that hits the gateway and is consider local.

@rytilahti
Copy link
Owner

See my comment in regarding to these errors: home-assistant/core#11048 (comment) -- PRs for adding "troubleshooting" or "FAQ" to the docs including this information would be greatly appreciated!

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