Plex losing connection to the file on mounted gdrive

Hi there,

So I’ve just moved some of my media library to gdrive via rclone. The drive is mounted using rclone mount and animosity22’s settings (awesome by the way, thanks).

I have added a new library and the media is found in plex, click play on another device and the streaming starts…

However, ~25 mins in to my stream, I am greeted with the following Plex error:
Playback has been stopped because the connection to the Plex Media Server has been lost. Please ensure the server is available and retry.

I can hit retry, and SOMETIMES the media starts again, sometimes not. But even when it does I get the same error another ~25 mins later.

I’m certain it’s not the connection to the server that’s the issue, as streaming from a library in which the files are local works like a charm. I have investigated the DEBUG log, all looks normal from what I can tell, with lots of chunk reads like below:
2018/10/18 19:29:59 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: Read: len=131072, offset=907595776
2018/10/18 19:29:59 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: >Read: read=131072, err=<nil>

However, after the last entry of this type, and a few of these (which seem to happen every second so I assume is a standard part of the DEBUG):
2018/10/18 19:30:00 DEBUG : : >Statfs: stat={Blocks:274877906944 Bfree:274617396315 Bavail:274877906944 Files:1000000000 Ffree:1000000000 Bsize:4096 Namelen:255 Frsize:4096}, err=<nil>
2018/10/18 19:30:00 DEBUG : : Statfs:
2018/10/18 19:30:00 DEBUG : : >Statfs: stat={Blocks:274877906944 Bfree:274617396315 Bavail:274877906944 Files:1000000000 Ffree:1000000000 Bsize:4096 Namelen:255 Frsize:4096}, err=<nil>

I get this:
2018/10/18 19:30:00 DEBUG : movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4: ChunkedReader.Read at 1980022784 length 1048576 chunkOffset 946130944 chunkSize 1073741824

And then this, which seems like rclone is closing the stream(?):
2018/10/18 19:30:01 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: Flush:
2018/10/18 19:30:01 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: >Flush: err=<nil>
2018/10/18 19:30:01 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: Flush:
2018/10/18 19:30:01 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: >Flush: err=<nil>
2018/10/18 19:30:01 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: Release:
2018/10/18 19:30:01 DEBUG : movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4: ReadFileHandle.Release closing
2018/10/18 19:30:01 DEBUG : &{movies/Plex Versions/Optimized for TV/Jurassic World_ Fallen Kingdom (2018).mp4 (r)}: >Release: err=<nil>

A few minutes after this, when the buffer has run out, I am greeted with the Plex error mentioned above.

On a side note, I also see rate limit errors in the log every so often, which is surprising because this is the first time in the last 24 hours I am using the mount. They appear to be intermittent and I wonder if they are telling the truth as they are in between reads of the film:
2018/10/18 19:08:54 DEBUG : pacer: Rate limited, sleeping for 8.069900486s (4 consecutive low level retries)
2018/10/18 19:08:54 DEBUG : pacer: low level retry 4/10 (error googleapi: Error 403: Rate Limit Exceeded, rateLimitExceeded)

Any help would be much appreciated, thanks.

rclone version shows what version?

Are you using your own API key or the standard rclone key?

What’s the player that is giving you the error?

rclone version shows what version?

rclone v1.43.1
os/arch: linux/amd64
go version: go1.11

Are you using your own API key or the standard rclone key?

Not 100% on this one, when setting up the remote I used auto config, pasted the auth link into a browser, and then pasted the verification code back into rclone.

What’s the player that is giving you the error?

Plex client for Amazon Fire Stick, v7.6.1.7056

So the error you gave was actually a plex error saying you lost a connection to the server and not really a rclone type error. You see the flush because the client closed out. There are some issues I’ve seen with the ATV players as they only request chunks of the file at a time and close out and re-open the file. It doesn’t matter much for local media, but for cloud stuff, it really sucks. For the plays you are having issue with, are they Direct Playing/DirectStreaming or Transcoding?

The 403s are more related to using the standard rclone API key which gets a lot of use. You can follow this if you want to create and use your own which would work better:

https://rclone.org/drive/#making-your-own-client-id

I’d grab the 1.44 (latest) version as well just to make sure as there are a few fixes in there that are worth it.

I see - do you think it would be worthwhile checking the Plex server logs? All direct play, most of my media is able to direct play. Haven’t tested on a transcode yet.

Awesome, just created one and updated the config. Wondered how people could see their API call metrics!

Have updated, thanks. Will try the same film now and see what happens, although don’t have DEBUG on atm.

It wouldn’t do much as it’s all the client.

Try turning off the option of Direct Play on the player and give it a test and see if it plays.

Good point, I could enable network logging and take a look mind you.

No specific option to turn off direct play, but have selected another quality to force the transcode and not a single issue! Are there any settings I can play around with, or do you think it’s best to find another client that doesn’t have issues with direct play (suggestions welcome)?

I personally never found a work around the client.

I put plex behind a proxy server though which there are a few guides on.

https://github.com/toomuchio/plex-nginx-reverseproxy is one, but I always found nginx to be a little too complex / overkill so I went with Caddy at https://github.com/mholt/caddy

It’s a much simpler setup/config, but with a proxy, it doesn’t seem to open and close the files. I have my config documented at https://github.com/animosity22/homescripts#plex-and-caddy-configuration

and if there isn’t an option to turn off direct play, which stinks on that client, you can perhaps try out the proxy. Since the client opens/closes it, there isn’t anything you can from the rclone side as you get seeing the latency hit from open / closing a cloud file repeatedly.

A cache configuration might also work if you want to try that, but I personally don’t use the cache backend since my setup has been rock solid for months.

1 Like

Interesting. Do you have any idea why putting it behind a proxy works? I can’t work out how this would make any difference as the Plex client picks up my server based on my login and just uses IP address and the standard port which is open. When using the proxy would I have to specify the proxied web address as a manual server?

Guessing you can do the same with Apache (which is what I’m running), so I’ll give it a Google.

The proxy keeps the connection alive even though the client open/closes it quickly.

You have to do a few steps to turn off the 32400 access and that’s documented in the links above.

I use a custom https address for my domain so it’s mapped to 443 instead of the 32400.

https://github.com/toomuchio/plex-nginx-reverseproxy has a good list of steps and explains what is needed to get a proxy to work. I’d use Caddy to be honest as the config insanely simple.

Hey Animosity,
It’s been a few months since this post but i’m experiencing the exact symptoms as original poster and have logs that match up with the events.

At the time of the thread you mention implementing a reverse proxy to solve for the issue. Peeking at your github it appears you’ve tweaked things and have been able to remove the proxy from plex. I’m having the issue with both plex and emby but curious if since October you’ve come up with a new and improved solution :slight_smile:

Thanks

If you’d like to make a new post with your settings, logs and such, I’d be more than happy to look at it.

I stopped using the proxy as it was needed in my setup as I’m all ATVs.

Closing out this old thread.