CarGuo/GSYVideoPlayer · error · InterruptedProxyCacheException

Reading source ${sourceInfo.url} is interrupted

Error message

Reading source ${sourceInfo.url} is interrupted

What it means

HttpUrlSource.read's generic IOException branch (after InterruptedIOException was checked first): any mid-stream IO failure - connection reset, premature EOF handling, TLS abort - is wrapped as ProxyCacheException('Error reading data from <url>'). It means the origin connection broke while the proxy was piping bytes to the cache/player.

Source

Thrown at gsyVideoPlayer-proxy_cache/src/main/java/com/danikula/videocache/HttpUrlSource.java:138

                    "https://github.com/danikula/AndroidVideoCache/issues.";
                throw new RuntimeException(message, e);
            } catch (ArrayIndexOutOfBoundsException e) {
                HttpProxyCacheDebuger.printfError("Error closing connection correctly. Should happen only on Android L. " +
                    "If anybody know how to fix it, please visit https://github.com/danikula/AndroidVideoCache/issues/88. " +
                    "Until good solution is not know, just ignore this issue :(", e);
            }
        }
    }

    @Override
    public int read(byte[] buffer) throws ProxyCacheException {
        if (inputStream == null) {
            throw new ProxyCacheException("Error reading data from " + sourceInfo.url + ": connection is absent!");
        }
        try {
            return inputStream.read(buffer, 0, buffer.length);
        } catch (InterruptedIOException e) {
            throw new InterruptedProxyCacheException("Reading source " + sourceInfo.url + " is interrupted", e);
        } catch (IOException e) {
            throw new ProxyCacheException("Error reading data from " + sourceInfo.url, e);
        }
    }

    private void fetchContentInfo() throws ProxyCacheException {
        HttpURLConnection urlConnection = null;
        InputStream inputStream = null;
        try {
            urlConnection = openConnection(0, 10000);
            long length = getContentLength(urlConnection);
            String mime = urlConnection.getContentType();
            inputStream = urlConnection.getInputStream();
            this.sourceInfo = new SourceInfo(sourceInfo.url, length, mime);
            this.sourceInfoStorage.put(sourceInfo.url, sourceInfo);
        } catch (IOException e) {
            HttpProxyCacheDebuger.printfError("Error fetching info from " + sourceInfo.url, e);
        } finally {

View on GitHub (pinned to e5d74d3aa9)

Solutions

  1. Catch ProxyCacheException in the player error path and trigger a smart retry: recreate the proxy url (getProxyUrl continues from cached offset) and resume playback at the saved position
  2. Implement onNetworkChanged handling: on connectivity regain, restart playback from last position
  3. Use a HeaderInjector/timeout tuning so slow origins are not cut off
  4. Do not disable proxy caching for this - the cache actually makes resume-after-error cheap since only the uncached tail is re-fetched

Example fix

// before
@Override public void onPlayError(String url, Throwable t) { finish(); }

// after - resume from cached data
@Override public void onPlayError(String url, Throwable t) {
    if (t instanceof ProxyCacheException || t.getCause() instanceof ProxyCacheException) {
        long pos = player.getCurrentPositionWhenPlaying();
        player.release();
        player.setUp(proxyCacheServer.getProxyUrl(url), true, cacheHeaders);
        player.startPlayLogic();
        player.onPrepareReusable(pos);
    }
}
Defensive patterns

Strategy: retry

Validate before calling

// check connectivity before resuming playback
ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getActiveNetworkInfo();
if (ni == null || !ni.isConnected()) { /* wait for network instead of retrying */ }

Try / catch

catch (ProxyCacheException e) {
    if (e instanceof InterruptedProxyCacheException) return; // shutdown, ignore
    resumePlaybackFromCachedOffset(url, lastPosition); // rebuild proxy url, seek to lastPosition
}

Prevention

When it happens

Trigger: The ProxyCache source-reader thread is pumping bytes into FileCache when the socket dies: server closed the connection, mobile network switched (WiFi<->cellular), or the CDN reset long-lived streams. Also thrown when read() is called with inputStream == null ('connection is absent!' variant inside the same method family).

Common situations: Network switching during playback; aggressive CDN idle resets; NAT timeouts on paused streams; flaky carrier connections. Pausing a video for minutes then resuming commonly triggers it.

Related errors


AI-assisted analysis of CarGuo/GSYVideoPlayer@e5d74d3aa9 (2026-08-14). Data as JSON: /api/errors/84410e25953694e9. Report an issue: GitHub.