Bug TVServerKodi causes a crash for TVservice
#1
Hi,

with latest stable OpenElec, and TVService v1.11.0.0, TVServerKodi version:1.10.0.128, I met a problem that causes TVservice to stop/crash sometimes...which is not nice. Apart from that, OpenELEC/Kodi and the TVServerKodi-plugin are playing beatifully & fast compared to the last time I was trying them (a few years ago) -and that's marvellous!!!

There's (maybe) an unhandled exception leaking from TVServerKodi.ConnectionHandler.HandleConnection()...? Here's an extract from TVService.log

Code:
[2015-10-11 12:01:37,562] [Log    ] [24       ] [DEBUG] - TVServerKodi: Handling command: GetChannelCount
[2015-10-11 12:01:37,577] [Log    ] [24       ] [DEBUG] - TVServerKodi: Handling command: GetScheduleCount
[2015-10-11 12:01:39,309] [Log    ] [23       ] [INFO ] - Tvservice stopped due to an unhandled app domain exception System.IO.IOException: Ei voi lukea tietoja siirtoyhteydestä: Etäpalvelin sulki aiemmin luodun yhteyden. ---> System.Net.Sockets.SocketException: Etäpalvelin sulki aiemmin luodun yhteyden
   kohteessa System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   kohteessa System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- Sisäisen poikkeuksen pinon jäljityksen loppu ---
   kohteessa System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   kohteessa System.IO.StreamReader.ReadBuffer()
   kohteessa System.IO.StreamReader.ReadLine()
   kohteessa TVServerKodi.ConnectionHandler.HandleConnection()
   kohteessa System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   kohteessa System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   kohteessa System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   kohteessa System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   kohteessa System.Threading.ThreadHelper.ThreadStart()
[2015-10-11 12:01:39,402] [Log    ] [PS StandbyWakeup] [DEBUG] - PS: LoadSettings()
[2015-10-11 12:01:39,418] [Log    ] [24       ] [DEBUG] - TVServerKodi: Handling command: GetRecordingCount
[2015-10-11 12:01:39,792] [Log    ] [TVService] [INFO ] - TV Service is being stopped
Reply
#2
Also informed MP team about this issue. Here:
http://forum.team-mediaportal.com/thread...ce.132378/
Reply
#3
Would be good to have full logs from Kodi and MediaPortal when this happens, so that it is possible to connect the crash to something happening in Kodi.

I wouldn't expect the MediaPortal team to fix this bearing in mind they are working on the next version of their TV server and don't see the same crash when MediaPortal is used as the front end.

Regards,

Mark
Reply
#4
I suppose I got TVservice.log posted here: http://goo.gl/Nikg6k

If I'm reading the log correctly ...TVServerKodi is trying to get some info from the client, but the client is no more there.TVServiceKodi gets an exception about that, but does not catch it, so the exception is passed to "higher"-layers...causing TVService to crash/stop. Something like that happening there?
Reply
#5
The issue was further discussed in the referred thread in MP forum. It seems that the exception handling in TVserverKodi-plugin would need some fixing...
Reply
#6
I've posted a new version of the TVServerKodi plugin that should catch the exception inside the plugin to prevent the TV server crash.
The additional try/catch should keep your TVServer running, but it does not solve the actual problem.

I'm still wondering why the exception happens. Do you also have the corresponding xbmc.log file for me?
Developer of the MediaPortal PVR addon and retired developer of the Argus-TV PVR-addon.
http://www.scintilla.utwente.nl/~marcelg/xbmc
Reply
#7
Thanks a lot margro!

...unfortunately I was a bit lazy and did not find out how to get the logs from OpenELEC when the problem happened...and now that I tried...it has already overwritten the logs from that time (or at least they are not in the zip file that I get using these instructions http://wiki.openelec.tv/index.php/OpenEL...rt_logs.3F )

...but I had a look at your commit and I'm pretty sure you nailed it, because the problem happened when I was setting up my OpenELEC box: I booted it a couple of times, and reconfigured my TVserver address, and changed the WOL settings as well -also...the box is using WLAN. So maybe my OpenELEC box got closed just during a piece of HandleConnection() which was not enclosed byt try-catch. Though, I can't immediately see which part of HandleConnection() would really take so long that such thing could happen. But well, with my luck it there's a microsecond of time to fail...I'll hit that slot with a 99% chance :-).

Never-ever used .net ...but is it OK to have the reader & cStream ".Dispose()" commands inside the try-catch? Or should they rather be in some "finally" or "using" sort of structure? I mean, would there be some sort of leak in case of an exception now?

But again, thanks a lot! I'll take the new version in use as soon as possible!
Reply
#8
Does this bug effect other platforms?

and in particular windows 7?

I'm setting up a new HTPC system and I'm having problems with the Live TV timing out and crashing the backend MP server

Thanks
Reply
#9
I've had the new version of the plugin running on my MP server for a few days, and have not experienced crashes (anymore/yet).

PoBear: you better post some logs...
Reply
#10
I'm down level on some of the software and I know the first thing that is going to be suggested is upgrading so there is no point me posting logs, I'm just trying to find out if it is a possibility so I can decide whether to upgrade sooner rather than later.

Thanks
Reply
#11
Well then, yes it is possibly the same problem. But it's equally possible that it's not the same problem. Nobody can judge with that amount of info, sorry!
Reply
#12
OK thanks.

I've been dodging doing an upgrade for some time as everything else is working without problem and live TV hasn't been a necessity up to now. I'll just have to bite the bullet!
Reply
#13
I seem to still be experiencing this problem, i have been trying to figure it out for a couple weeks now. MP can play channels but I could not get my kodi clients to play anything. I am also experiencing an issue with having to restart the TV Service over and over. That is what led me here.

My set up is MP running on a Win10 computer that is serving several RaspberryPI clients running OSMC/Kodi. MP on the Win10 server work perfectly fine. I can tune to and watch channels. Everything seems to be set up correctly. Reviewing the TVService log pasted below, shows that the TVSerivce keep shutting down.

http://pastebin.com/At0h9fFJ - TVService Log

Then on the client side this same error keeps repeating

17:41:53 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: MPTV::Socket::ReadLine: (Winsock error=10054) Connection reset by peer
17:41:53 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: SendCommand - Failed.
17:41:53 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: SendCommand2: reconnect failed.
17:41:54 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket::connect 192.168.1.5:9596
17:41:54 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket::connect: (Winsock error=10061) Connection refused
17:41:54 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Could not connect to MediaPortal TV Server backend
17:41:54 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket:Confusedend: (Winsock error=10057) WSA Error
17:41:54 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket:Confusedend - failed to send data
17:41:55 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket::connect 192.168.1.5:9596
17:41:55 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket::connect: (Winsock error=10061) Connection refused
17:41:55 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Could not connect to MediaPortal TV Server backend
17:41:55 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: SendCommand2: reconnect failed.
17:41:55 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket:Confusedend: (Winsock error=10057) WSA Error
17:41:55 T:6796 ERROR: AddOnLog: MediaPortal PVR Client: Socket:Confusedend - failed to send data


When I try to play Live TV i get this in the client log:
17:12:08 T:6192 NOTICE: DVDPlayer: Opening: pvr://channels/tv/All channels/pvr.mediaportal.tvserver_182.pvr
17:12:08 T:6192 WARNING: CDVDMessageQueue(player):Tongueut MSGQ_NOT_INITIALIZED
17:12:08 T:4580 NOTICE: Thread DVDPlayer start, auto delete: false
17:12:08 T:4580 NOTICE: Creating InputStream
17:12:08 T:4580 NOTICE: AddOnLog: MediaPortal PVR Client: Open Live stream for channel uid=182
17:12:50 T:4580 ERROR: AddOnLog: MediaPortal PVR Client: SendCommand - Failed.
17:12:50 T:4580 ERROR: AddOnLog: MediaPortal PVR Client: Could not start the timeshift for channel uid=182. Reason:
17:12:50 T:4580 ERROR: AddOnLog: MediaPortal PVR Client: GetLiveStreamURL for uid=182 returned no URL
17:12:50 T:4580 ERROR: CDVDInputStreamPVRManager::Open - error opening []


Here is the complete client log

http://pastebin.com/gUfs9GgZ

Any help would be greatly appreciated. Thank you
Reply
#14
Thanks for the log files. I will dive into the TVServerKodi sources to check if I can find a possible cause. If not, I will need to add at least somewhere an additional error handler to catch this exception to prevent the TVServer from stopping. I'm actually surprised that these crashes suddenly pop-up since that part of the TVServerKodi plugin was not even written by me and it is already the same since XBMC Dharma.
Developer of the MediaPortal PVR addon and retired developer of the Argus-TV PVR-addon.
http://www.scintilla.utwente.nl/~marcelg/xbmc
Reply
#15
Please let me know if you need anything else i will be more then happy to test for you too. Thanks again for all your help.
Reply

Logout Mark Read Team Forum Stats Members Help
TVServerKodi causes a crash for TVservice0