ursli 6 Posted September 9, 2015 Share Posted September 9, 2015 (edited) Hi there, As title already suggests, whenever I use the kodi emby app on the go via the net the connection on my local server stays open even though I've disconnected a long time ago, the dashboard also correctly mentions that the user in question has disconnected. This turns into a problem because I parse netstat on my server to see if there's activity on certain ports so it can shut down when it's not needed. If I don't restart the emby server the connections stay open indefinitely. I've had a look if the connection stays open when I just use the mobile webfrontend in my browser and there the problem doesn't appear, so I'm pretty sure something goes wrong in the emby for kodi implementation. I'm running Kodi 14.2 on my mobile Emby for Kodi 1.1.13 The server version is 3.0.5675.1 (running on Linux) netstat output: netstat | grep 55009 tcp 0 0 xbmc.local:55009 OPENWRT.lan:58352 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58350 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58351 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58349 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58269 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58267 ESTABLISHED And another netstat after scrolling around the library a bit, as you can see the connections just keep stacking up without gracefully disconnecting like they do with the webUI. netstat | grep 55009 tcp 0 0 xbmc.local:55009 OPENWRT.lan:58352 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58699 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58350 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58351 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58595 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58349 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58269 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58597 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58447 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58445 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58596 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58594 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58732 ESTABLISHED tcp 0 0 xbmc.local:55009 OPENWRT.lan:58267 ESTABLISHED Edited September 9, 2015 by ursli Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 And does shutting down Kodi closes those connections? Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 I've added closing connection in beta, because I realized I forgot to do this. So the problem might not exist in beta. Would you be willing to test and let me now? Link to comment Share on other sites More sharing options...
ursli 6 Posted September 9, 2015 Author Share Posted September 9, 2015 Will give that a go, thanks for the quick reply. Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 (edited) Awesome, basically just install the beta repo, install the emby for kodi version over your stable. You'll have to reset rescan your library to gain proper functionality since a lot has changed since in the database structure. However, hopefully this problem is already solved. If not, we'll go from there and I'll have to do more research about this. Edited September 9, 2015 by Angelblue05 Link to comment Share on other sites More sharing options...
ursli 6 Posted September 9, 2015 Author Share Posted September 9, 2015 No change sadly, restarted emby server, made sure all connections are closed. Updated to emby beta, reset my database and checked again. In response to your question earlier: I do close Kodi before I check, and I also give it 5min so connections got time to properly timeout. Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 (edited) Ok, so you shut down Kodi and the connections are still open after 5 minutes? That's very odd... I'll have to look more into it. The way we are currently doing this is there is only one connection opened. And then it's closed when Kodi is shut down or the profile is switched... Edited September 9, 2015 by Angelblue05 Link to comment Share on other sites More sharing options...
ursli 6 Posted September 9, 2015 Author Share Posted September 9, 2015 Yes, as I mentioned earlier it can be days since I closed Kodi and the connections are still open. :/ Unless I notice the linux server is constantly on and then restart emby-server. 1 Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 Ok, thanks for reporting this @@ursli - Looking into it right now to see what could be missing. Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 (edited) @@ursli Can you give this test build a try? Thanks Just install from zip (that's it, no need for library reset) over the current version and let me know if the tcp connections are closed appropriately afterwards. If it still doesn't work, I might have found something else to try as well. Edited September 9, 2015 by Angelblue05 Link to comment Share on other sites More sharing options...
ursli 6 Posted September 9, 2015 Author Share Posted September 9, 2015 Doesn't seem to help, at least I've closed Kodi since 5min now and the connections are still open. I noticed this in my Kodi logs, not sure if that has anything to do with the open tcp ports though. 22:52:14 T:6764 ERROR: CPythonInvoker(1, C:\Users\rebe\AppData\Roaming\Kodi\addons\plugin.video.emby\service.py): script didn't stop in 5 seconds - let's kill it 22:52:15 T:5860 NOTICE: Sync DB -> syncDatabase Exiting 22:52:15 T:4188 WARNING: CPythonInvoker(1, C:\Users\rebe\AppData\Roaming\Kodi\addons\plugin.video.emby\service.py): the python script "C:\Users\rebe\AppData\Roaming\Kodi\addons\plugin.video.emby\service.py" has left several classes in memory that we couldn't clean up. The classes include: class XBMCAddon::xbmcgui::Window,class XBMCAddon::xbmcgui::Window,class XBMCAddon::xbmcgui::Window,class XBMCAddon::xbmcgui::Window,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmcaddon::Addon,class XBMCAddon::xbmc::Player,class PythonBindings::XBMCAddon_xbmc_Monitor_Director,class PythonBindings::XBMCAddon_xbmc_Monitor_Director,class PythonBindings::XBMCAddon_xbmc_Monitor_Director 22:52:15 T:6764 NOTICE: stopped Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 9, 2015 Share Posted September 9, 2015 (edited) no, this is normal stuff. Nothing to do with the issue. You exited while the start up sync was going, this is why you got the message.... Ok. I'll keep looking into it and let you know once I have another build to make you test. Edited September 9, 2015 by Angelblue05 1 Link to comment Share on other sites More sharing options...
ursli 6 Posted September 10, 2015 Author Share Posted September 10, 2015 (edited) Yes, port 55009 is set up as the https port, and xbmc is indeed my linux htpc where emby-server is running on. I've also tried it via the http port (8096) on my local network and I had the same thing happening, ports stayed open. I just don't check for activity on 8096 thats why I didn't notice it earlier. edit: Here is another netstat while running Kodi on my local network on the http port without resolving hostnames. The first connection is Kodi running on the local linux htpc, from the second connection onwards it's a pc on the local network. tcp 0 0 192.168.22.15:44495 192.168.22.15:8096 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50125 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50309 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.15:44495 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50298 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50153 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50302 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50342 ESTABLISHED tcp 0 0 192.168.22.15:8096 192.168.22.5:50158 ESTABLISHED Edited September 10, 2015 by ursli Link to comment Share on other sites More sharing options...
ursli 6 Posted September 10, 2015 Author Share Posted September 10, 2015 (edited) No, that netstat output is 5min after I've closed Kodi, so same problem. (Still in use now even though 192.168.22.5 is shut down since 40min) Edited September 10, 2015 by ursli Link to comment Share on other sites More sharing options...
ursli 6 Posted September 10, 2015 Author Share Posted September 10, 2015 (edited) Kodi is closed on 192.168.22.5, I've just tested again to make sure I didn't have some dead Kodi process in the task-manager. And as mentioned before I can turn off the PC and the ports stay open according to netstat. Regarding the OS problem, wouldn't that also mean that any connection to emby-server stays open? I can use the webUI with my browser and connections close after about 1-2min (Which is the default timeout I guess). The problem only appears if I'm running the emby for Kodi addon. After some more fiddling I've noticed that some connections do close with the latest emby for Kodi addon Angelblue attached here, not all of them though. Confusing stuff... Edited September 10, 2015 by ursli Link to comment Share on other sites More sharing options...
ursli 6 Posted September 10, 2015 Author Share Posted September 10, 2015 (edited) If it would only be for a while I could certainly live with it, but they seem to stay open for days without end in sight. I guess I could parse server log files or something and restart emby-server if a user disconnects as a work around, but that sounds like I could end up having trouble if multiple users use the server at the same time. One more observation: It does seem to matter how I close Kodi, if I just press the X on the window more connections stay open, if I do a proper exit via the Kodi skin connections seem to close properly. edit: Or it's just very random, sometimes connections close properly also when I press the X. I'm out of ideas, right now I guess I another way would be to run killcx every morning and just kill all tcp connections to 55009. Worst case scenario I kill connections when somebody is still on, but like this the htpc at least shuts down for the time being. Edited September 10, 2015 by ursli Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 10, 2015 Share Posted September 10, 2015 Ok well if what I did seems to help, then perhaps the close connection header will do the trick. Never close Kodi with the x, Kodi needs to be closed via shutdown otherwise you will have many problems because nothing (addons especially) gets notified in Kodi that shut down is happening. Sent from my iPhone using Tapatalk 1 Link to comment Share on other sites More sharing options...
Angelblue05 4130 Posted September 18, 2015 Share Posted September 18, 2015 @@ursli Can you let me know which version you are on? I have some time to make a build to test out my solution to try and close ports. Let me know. Link to comment Share on other sites More sharing options...
Recommended Posts