elbowz / xbmc.service.pushbullet

Pushbullet Notification Client
GNU General Public License v3.0
22 stars 12 forks source link

Service dies on network disconnect/suspend #9

Closed ruuk closed 9 years ago

ruuk commented 9 years ago

I've tested both suspend and disconnecting from the network and the service dies silently (no log messages).

The only evidence I see in the log is the message:

13:17:57 T:140560564410112   ERROR: No handlers could be found for logger "root"

This message also appears on Kodi shutdown. I'm pretty sure this message comes from the WebSocket api.

elbowz commented 9 years ago

shit...with the develop branch?

I have tried and It seems works :( ...I have done some mistake, sorry

ruuk commented 9 years ago

Yeah, the develop branch.

There are 2 things going on here I think.

One is that a socket can remain valid for 5 minutes during a network disconnect, but eventually if the network is disconnected long enough the socket will have an error. So you would have to leave the socket disconnected for a while to really test this. I'm not sure how this works for suspend (at least on Linux systems, see below about windows) because it may not count the time during suspend as part of the timeout duration.

The other issue I read about is that windows specifically resets TCP connections when a network interface goes down (which is stupid). So, since I am testing on windows, the problem happens immediately, whereas on Linux it it takes a while (ie the socket can survive interruptions of minutes).

I need to do more testing before I know what is exactly going on. It seems weird that there is no error or debug message in the log, so perhaps I will have to wait longer to see if something else happens. If something does take a while to happen, then we will need a way to detect that the socket is no longer working.

elbowz commented 9 years ago

5 minutes? Where have you find this value? I have tested only for 1 or 2 minutes :(

It seems weird that there is no error or debug message in the log

I don't know if this can be related, but seems that python threads can't throw error: http://stackoverflow.com/questions/2829329/catch-a-threads-exception-in-the-caller-thread-in-python

...and my websocket is in a thread...

ruuk commented 9 years ago

5 minutes? Where have you find this value? I have tested only for 1 or 2 minutes :(

Just something in a web search. It said linux could be up to 5 minutes. It varies. In any case, the device could be suspended for a day, and we don't want the service to not work when they resume.

It seems weird that there is no error or debug message in the log I don't know if this can be related, but seems that python threads can't throw error: http://stackoverflow.com/questions/2829329/catch-a-threads-exception-in-the-caller-thread-in-python

...and my websocket is in a thread...

Well, threads can throw an error, they just can't be caught outside the thread. I think we can use an Event() or something and in Pushbullet._websocketThread() after self._ws.run_forever(ping_interval=6, ping_timeout=self.ping_timeout) returns, we check for xbmc.abortRequested and set the event. The sleep loop in Service.init() could check for this event and then re-start the service. This is just a quick idea, but something like this should work.

elbowz commented 9 years ago

I'll glad to see your solution ended :)

...I have just retried develop branch, and I can confirm that on Linux works good. I have waited 10 minutes (non more)...

But this works only with: self._ws.run_forever(ping_interval=6, ping_timeout=self.ping_timeout)

if you don't set ping_interval, the socket dies and this error is throw:

09:02:54 T:140659227932416 ERROR: No handlers could be found for logger "root"

boh :)

ruuk commented 9 years ago

I'll glad to see your solution ended :)

What? I don't understand what you mean.

...I have just retried develop branch, and I can confirm that on Linux works good. I have waited 10 minutes (non more)...

But this works only with: self._ws.run_forever(ping_interval=6, ping_timeout=self.ping_timeout)

if you don't set ping_interval, the socket dies and this error is throw:

09:02:54 T:140659227932416 ERROR: No handlers could be found for logger "root" boh :)

To bad it doesn't work on windows. I'm surprised it doesn't get disconnected from the Pushbullet end after ten minutes.

elbowz commented 9 years ago

Linux...is Linux :P

I don't though, but XBMC works also on my VirtualBox guest machine with Windows 7 (I don't have daughter ;) ...I'll try to mess up with the code.

what machine do you use?

ruuk commented 9 years ago

I develop on Ubuntu My main device for watching stuff is an Ouya I have Virtual Machines for testing Win8, Win7, Vista and OSX I have a Raspberry Pi for testing with OpenElec, Raspbian and RaspBMC I have a Samsung Note 3 (phone) for normal android testing And I have my daughters laptop if I need a real Windows machine

elbowz commented 9 years ago

Great! You could test whole XBMC platforms supported...

but I like leave this job to the users :)

ruuk commented 9 years ago

So do I, but when an error is found, sometimes a debug log isn't enough :) Sometimes you need to duplicate it yourself.

elbowz commented 9 years ago

Yeah, I agree with you...but we are the only that use issue form on github ;) for now...

ruuk commented 9 years ago

Just wanted to let you know that the code from the disconnect branch fixes the issue with sleep/suspend. Tested it with my daughters laptop, and everything was working great after resuming. I guess I'll close this issue.

elbowz commented 9 years ago

Great! Thank your daughter!