CarGuo/GSYVideoPlayer · error · ProxyCacheException
Error reading data from ${sourceInfo.url}
Error message
Error reading data from ${sourceInfo.url} What it means
HttpUrlSource.openConnection implements manual redirect following: on 301/302/303 it takes the Location header and re-opens, counting hops. If redirectCount exceeds MAX_REDIRECTS (5), it throws ProxyCacheException('Too many redirects: N'). This guards against redirect loops (A->B->A) and auth walls that keep bouncing the proxy.
Source
Thrown at gsyVideoPlayer-proxy_cache/src/main/java/com/danikula/videocache/HttpUrlSource.java:140
} 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 {
ProxyCacheUtils.close(inputStream);
if (urlConnection != null) {View on GitHub (pinned to e5d74d3aa9)
Solutions
- Verify the URL in a browser/curl -L and fix the server-side redirect loop
- Re-acquire a fresh signed URL before playback instead of reusing a stale one
- Whitelist the captive-portal check: detect portal redirect and prompt the user to sign in
- If a legitimate chain exceeds 5, fork and raise MAX_REDIRECTS in a custom HttpUrlSource
Example fix
# before curl -I "https://cdn.example.com/v.mp4?token=stale" # HTTP 302 -> https://auth.example.com/login # HTTP 302 -> https://cdn.example.com/v.mp4?token=stale (loop) # after - fetch fresh url at play time String freshUrl = api.getPlaybackUrl(videoId); player.setUp(proxyCacheServer.getProxyUrl(freshUrl), true, headers);
Defensive patterns
Strategy: validation
Validate before calling
// detect a redirect loop before playing
String loc = url; int hops = 0;
while (hops++ < 5) {
HttpURLConnection c = (HttpURLConnection) new URL(loc).openConnection();
int code = c.getResponseCode();
if (code/100 == 3) loc = c.getHeaderField("Location"); else break;
}
if (hops >= 5) throw new IllegalArgumentException("redirect loop on " + url); Try / catch
catch (ProxyCacheException e) {
if (String.valueOf(e.getMessage()).contains("Too many redirects")) {
url = api.getFreshPlaybackUrl(videoId); // fresh signed url, then replay
} else throw e;
} Prevention
- Fetch playback urls at play time when they are signed/authenticated
- Detect captive portals before streaming
- Fix server-side redirect loops (A->B->A)
When it happens
Trigger: A redirect cycle on the origin (common with tokens: url redirects to a login/refresh page that redirects back); a CDN chain longer than 5 hops; a Location header pointing back to the same url; captive portals that redirect every request to a sign-in page.
Common situations: Expired auth tokens causing bounce between content and auth endpoints; hotel/airport captive portals while caching; misconfigured server redirect rules; deep multi-CDN chains (rare but real with geo-routing).
Related errors
- Error starting local proxy server
- Error opening connection for ${sourceInfo.url} with offset $
- Reading source ${sourceInfo.url} is interrupted
- Too many redirects: ${redirectCount}
- Error reading source ${errorsCount} times
AI-assisted analysis of CarGuo/GSYVideoPlayer@e5d74d3aa9 (2026-08-14).
Data as JSON: /api/errors/6642bae0024e21c9.
Report an issue: GitHub.