Jump to content

Problems running Emby as a Windows Service


halter73

Recommended Posts

After missing a recording after an unexpected Windows restart, I followed the Running Emby Server as a Windows Service guide. Unfortunately, I've run into a few issues.

The first problem is that I'm getting alerts that "Check for application updates failed" and "Check for plugin updates failed". Here's the stack trace for one of one of the the application update failure:

2020-09-22 10:08:50.521 Error TaskManager: Error
	*** Error Report ***
	Version: 4.5.0.50
	Command line: C:\Users\Stephen\AppData\Roaming\Emby-Server\system\EmbyServer.dll -service
	Operating system: Microsoft Windows 10.0.20215
	Framework: .NET Core 3.1.8
	OS/Process: x64/x64
	Runtime: C:/Users/Stephen/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll
	Processor count: 8
	Data path: C:\Users\Stephen\AppData\Roaming\Emby-Server\programdata
	Application path: C:\Users\Stephen\AppData\Roaming\Emby-Server\system
	System.Net.Http.HttpRequestException: System.Net.Http.HttpRequestException: No such host is known.
	 ---> System.Net.Sockets.SocketException (11001): No such host is known.
	   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
	   --- End of inner exception stack trace ---
	   at Emby.Server.Implementations.HttpClientManager.CoreHttpClientManager.SendAsyncInternal(HttpRequestOptions options, String httpMethod)
	   at Emby.Server.Implementations.HttpClientManager.CoreHttpClientManager.SendAsync(HttpRequestOptions options, String httpMethod)
	   at MediaBrowser.Common.Updates.GithubUpdater.CheckForUpdateResult(String organzation, String repository, Version minVersion, PackageVersionClass updateLevel, String assetFilename, String packageName, String targetFilename, TimeSpan cacheLength, CancellationToken cancellationToken)
	   at Emby.Server.Implementations.ApplicationHost.CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.SystemUpdateTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: System.Net.Http
	TargetSite: Void MoveNext()
	InnerException: System.Net.Sockets.SocketException: No such host is known.
	Source: System.Private.CoreLib
	TargetSite: Void Throw()
	   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
	

That wasn't the only request failure, but some other requests made by the same prcess seemed to have succeeded judging by logs like "Info HttpClient: GET https://www.thetvdb.com..." and "Info HttpClient: GET https://api.themoviedb.org/3/...". I also don't see this issue when I stop the service and launch "Emby Server" normally via the start menu shortcut.

Is this a known issue? Do I have to stop the service and manually launch "Emby Server" from the start menu to get "automatic" updates now that I'm running Emby as a service?

The second problem I noticed is that a bunch of embytray.exe processes get launched after a while if I run EmbyServer as a service. This ends up filling up my tray. The restart option when right clicking the tray doesn't seem to do anything. Stoping the embytray.exe processes using the right click menu in the tray, not only stops that instance of embytray.exe but also the EmbyService process. I have to go into Task Manager to kill the  embytray.exe processes to get rid of them.

I think this is related to something trying to start "Emby Server" once an hour despite it already running as  a service. This leads to logs like the following:

2020-09-22 14:55:12.561 Error Main: Error in appHost.Init
	*** Error Report ***
	Version: 4.5.0.50
	Command line: C:\Users\Stephen\AppData\Roaming\Emby-Server\system\EmbyServer.dll -noautorunwebapp
	Operating system: Microsoft Windows 10.0.20215
	Framework: .NET Core 3.1.8
	OS/Process: x64/x64
	Runtime: C:/Users/Stephen/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll
	Processor count: 8
	Data path: C:\Users\Stephen\AppData\Roaming\Emby-Server\programdata
	Application path: C:\Users\Stephen\AppData\Roaming\Emby-Server\system
	SQLitePCL.pretty.SQLiteException: Busy: database is locked - PRAGMA journal_mode
	SQLitePCL.pretty.SQLiteException: Exception of type 'SQLitePCL.pretty.SQLiteException' was thrown.
	   at SQLitePCL.pretty.SQLiteDatabaseConnection.PrepareStatement(String sql, String& tail)
	   at SQLitePCL.pretty.DatabaseConnection.PrepareStatement(IDatabaseConnection This, String sql)
	   at Emby.Sqlite.BaseSqliteRepository.CreateConnection(Boolean isReadOnly)
	   at Emby.Server.Implementations.Data.SqliteItemRepository.Initialize(SqliteUserDataRepository userDataRepo, IUserManager userManager)
	   at Emby.Server.Implementations.ApplicationHost.InitDatabases()
	   at Emby.Server.Implementations.ApplicationHost.Init()
	   at EmbyServer.HostedService.StartAsync(CancellationToken cancellationToken)
	Source: SQLitePCL.pretty
	TargetSite: SQLitePCL.pretty.IStatement PrepareStatement(System.String, System.String ByRef)


Thankfully, a second instance of EmbyServer doesn't run due to the locked database, but this seems to be creating addtional embytray.exe processes. Disabling the EmbyServer startup item in Task Manager seems to fix the issue of multiple embytray.exe processes, but then I don't get any embytray.exe processes at all. How do I launch the embytray.exe process just once when I log in?

Edited by halter73
Link to comment
Share on other sites

Hi, no, the failed requests are not a known issue. Is it possible the network connection was idle for a while and something was shut down?

Link to comment
Share on other sites

I haven't seen a "Check for application updates failed" or "Check for plugin updates failed" log since the 24th. Maybe there really were some transient network issues. Or is this something that can only happen when EmbyServer starts? Because that also might explain it.

What's still super annoying is the following:

image.png.fb11ce4bc7392bad790c24447c623ab0.png

image.png.e289213013379681d9c2933eeecb9eb5.png

And that's not even half the embytray.exe processes.

And of course, there's a bunch of "SQLitePCL.pretty.SQLiteException: Busy: database is locked - PRAGMA journal_mode" logs associated with each tray icon. I thought this was due to Emby still being an enabled startup item, but I disabled it and restarted and it's still an issue.

image.png.4096d8970c1edb361628d662769b6943.png 

Do I need to disable something else? Do I also need to completely delete "%UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\Emby Server.lnk"? It'd be nice if I could keep it there so it's easy to reenable if I decide to get rid of the service. I thought disabling it in Task Manager would be enough.

I'm starting to think that this isn't related to any startup item at all and it's EmbyServer.exe launching all these embytray.exe processes somehow. As I'm sure you can understand, this is pretty frustrating, but I don't want to miss recordings either.

Edited by halter73
Link to comment
Share on other sites

Happy2Play
26 minutes ago, halter73 said:

I don't want to miss recordings either.

The Schedule recordings are doing this via Windows Scheduled Tasks from my understanding.  Will look for similar previous topics.

Link to comment
Share on other sites

Yes. The tray icons do remain. They are backed by running embytray.exe processes.

After I kill all the embytray.exe processes with Task Manager, hovering over the tray icons does clear them of course.

Link to comment
Share on other sites

BTW, I think you're right that this has something to do with scheduled recordings. It looks like I get a new tray icon every time a scheduled recording starts.

Do you have any idea what's launching EmbyServer with the "-noautorunwebapp" flag and how to stop it? Looking at the logs, it seems every time EmbyServer is launched with that flag, I get the "SQLitePCL.pretty.SQLiteException: Busy: database is locked - PRAGMA journal_mode" error and a new tray icon.

 

Link to comment
Share on other sites

So the problem seems clearly related to the scheduled tasks:

image.png.2adf8a8dda920071e77d8c81a46a26ac.png

These should be unnecessary since I'm running Emby as a service, right? How do I stop Emby from scheduling these tasks?

Link to comment
Share on other sites

Happy2Play

@Luke or someone more knowledgeable of DVR on Windows, will have to comment but I think it has to do with Waking or ensuring Emby is running to do your scheduled recordings.  But I would expect more reports of this if it were a wide spread issue unless something has changed recently.

Link to comment
Share on other sites

There's currently no way to stop this. What I would do is delete the existing windows scheduled tasks. I think what we'll do is just stop trying to schedule wakes when running as a service since it's not supported anyway.

Link to comment
Share on other sites

Quote

These should be unnecessary since I'm running Emby as a service, right?

No, that's not true. You could be running as a service and still have the machine go to sleep, so therefore it would need to wake up in order to record.

Link to comment
Share on other sites

At least in my case, I don't let my PC running Emby fall asleep. It would be better if Emby could still wake the PC when in service mode, but not scheduling wakes when running as a service is a good enough fix for me. Thanks!

Out of curiosity, do you recommend Linux (running in docker?) over Windows for running Emby?

Link to comment
Share on other sites

1 minute ago, halter73 said:

 

Out of curiosity, do you recommend Linux (running in docker?) over Windows for running Emby?

Hi, no, I think it runs well on any of the major OS's, so my recommendation would be the one you're most comfortable with.

Link to comment
Share on other sites

  • 3 months later...

I see this thread is a bit old... not sure this qualifies as a necro :)

I'm having the same exact issue...  I just checked and I had ~20 instances of embytray.exe running, and I"ve noticed this previously.  Icons in the systray and in task manager Processes tab.  They aren't necessarily "hurting" anything (performance) or consuming any resources, but my OCD is killing me seeing all of the icons in systray.

I found the Task Scheduler events to wake for recording and deleted them, however is there a fix in the works? maybe a toggle to enable/disable the function in settings?

Link to comment
Share on other sites

20 hours ago, chzx said:

I see this thread is a bit old... not sure this qualifies as a necro :)

I'm having the same exact issue...  I just checked and I had ~20 instances of embytray.exe running, and I"ve noticed this previously.  Icons in the systray and in task manager Processes tab.  They aren't necessarily "hurting" anything (performance) or consuming any resources, but my OCD is killing me seeing all of the icons in systray.

I found the Task Scheduler events to wake for recording and deleted them, however is there a fix in the works? maybe a toggle to enable/disable the function in settings?

Hi there, how are you shutting down emby server? If you're just killing the process from the task manager then that might be why this happens. If you shutdown the server normally using the buttons in the web interface, then this shouldn't happen.

Link to comment
Share on other sites

@Luke - I rarely shutdown my server.  It has been up and running for a couple of weeks and I normally only shut it down for critical Windows updates.  Since I deleted all of the Task Scheduler events the recordings that were scheduled last night did not spawn a new tray icon.  I did previously kill the instances of embytray.exe in Task Manager... Should I have just stopped and restarted the server via the web management console?

I did reboot my server last night for an update, so will see if the Task Scheduler events are created again this evening and if new systray icons are spawned for embytray.exe.

 

@pwhodges - I used nssm long ago as described in the guide to successfully install and run Emby as a service... So not sure what you meant by your statement.  Can you elaborate?

 

Edited by chzx
Link to comment
Share on other sites

pwhodges

No more than it says - I am running Emby as a service and do not have the problem you describe. 

Using nssm is now the recommended way, but when I set it up there were other options described, so I didn't know how you might have organised it.  If you are using nssm, then the problem is elsewhere (so long as you are only using nssm - it gets cranky if you use the Windows service manager to start and stop an nssm-based service).

Paul

Link to comment
Share on other sites

Understood, Paul.  Thank you for clarifying.

I'm using nssm and only nssm, however I was killing the embytray.exe services via Task Manager when I saw there were multiple instances running. (Right clicking the tray icon and killing them that way occasionally)

Reading the previous posts, I also deleted the Task Scheduler events that were present which appears to have eliminated the embytray.exe from respawning last night when my scheduled recordings kicked off.  As stated in my previous post, I updated Windows last night and Emby service successfully started as intended upon reboot (as it always has).  Now I just need to wait and see if the multiple tray services and processes kick off again when my scheduled recordings begin this evening.

If so, I will report back with screen caps so maybe there is some clarity around what I'm reporting.

Charlie

Link to comment
Share on other sites

By the way newer versions of the server won't try to schedule system wakes for recordings when running as a windows service, so if that is indeed the problem, then it should clear up as your current task scheduler entries expire.

But then again now that I think about it, if you ever run the server as a normal app, even for a short period of time, it may end up adding them back.

Link to comment
Share on other sites

  • 2 weeks later...

Update:  After deleting the Task Scheduler Events and restarting the server, the Emby Service started as expected and I am no longer getting a plethora of embytray.exe icons in the system tray/notification tray when my daily recordings kick off.

Appreciate the prompt feedback and advice.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...