Getting a 403 response code error from ExoPlayer - android-tv

I am randomly getting 403 error from google DAI url. Sometime no issue the whole day. Sometime it happens when start playing, sometime it happens after several minutes playing. This happens on live streaming and full screen live streaming.
Here are the logs:
onLoadError() called with: eventTime = [com.google.android.exoplayer2.analytics.AnalyticsListener$EventTime#c2e375b], loadEventInfo = [com.google.android.exoplayer2.source.MediaSourceEventListener$LoadEventInfo#fed7bf8], mediaLoadData = [com.google.android.exoplayer2.source.MediaSourceEventListener$MediaLoadData#db388d1], error = [com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403], wasCanceled = [false]
ExoAnalyticsLogger: onLoadStarted() called with: eventTime = [com.google.android.exoplayer2.analytics.AnalyticsListener$EventTime#bc71f36], loadEventInfo = [com.google.android.exoplayer2.source.MediaSourceEventListener$LoadEventInfo#90eee37], mediaLoadData = [com.google.android.exoplayer2.source.MediaSourceEventListener$MediaLoadData#d7a5fa4]
ExoPlayerImplInternal: Source error.
com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:211)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:147)
at com.google.android.exoplayer2.source.hls.HlsMediaChunk.loadMedia(HlsMediaChunk.java:267)
at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:214)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:320)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
ExoAnalyticsLogger: onLoadError() called with: eventTime = [com.google.android.exoplayer2.analytics.AnalyticsListener$EventTime#65df8c2], loadEventInfo = [com.google.android.exoplayer2.source.MediaSourceEventListener$LoadEventInfo#fda36d3], mediaLoadData = [com.google.android.exoplayer2.source.MediaSourceEventListener$MediaLoadData#6cfd210], error = [com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403], wasCanceled = [false]
Encountered error
com.google.android.exoplayer2.ExoPlaybackException
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:349)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:211)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:147)
at com.google.android.exoplayer2.source.hls.HlsMediaChunk.loadMedia(HlsMediaChunk.java:267)
at com.google.android.exoplayer2.source.hls.HlsMediaChunk.load(HlsMediaChunk.java:214)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:320)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

Based from this thread, there might be an issue with the cookie handler/manager. Make sure that you are using the same CookieHandler in both your okhttp service class and the exo player activity. You may also check this link for additional reference.

Check out this thread regarding storing cookies. Assuming you're streaming with Akamai url, the solution solved the 403 issue for me.
Note you'll need to implement
com.squareup.okhttp3:okhttp-urlconnection:4.6.0
com.google.android.exoplayer:extension-okhttp:2.11.4
to get JavaNetCookieJar and OkHttpDataSourceFactory.

Related

Httpwebrequst returns 500 internal server error while sending jsonconvert.serializeobject

We are sending JsonConvert.SerializeObject(lstobject); to the URL here. lstobject is a large list sent to the url.error also returned after 3 minutes to log error how to make webrequest to wait 5 minutes.
var httpWebRequest = (HttpWebRequest)WebRequest
.Create(ConfigurationManager.AppSettings["JsonPayloadPostUrl"]
.ToString());
httpWebRequest.Timeout = 1000000;
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(jsonPayload);
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var responseText = streamReader.ReadToEnd();
}
Ee have used httpWebRequest.Timeout = 1000000; but the server is unable to send request back in less than 5 minutes. How to make request to wait for server for response ?
I might be missing something reading your question, but HTTP 500 server error means that the server has provided a response, saying it encountered some internal issue. So you cannot prevent it by setting a bigger timeout on the Request side.
Following https://www.w3.org/Protocols/HTTP/HTRESP.html
Internal Error 500
The server encountered an unexpected condition which prevented it from
fulfilling the request.
I would say either your request is not properly built, or the server has some application-side issue.
Coming back to the timeout setting way, I think it looks properly. Please note that this time might be taking into account topics like DNS name resolution etc. which in turn might require a bit more time than it seems in the first place. This shouldn't be a problem in your case though, looking at the value you are trying to set.

HTTP.call throws errors instead of returning response

I am working with the Facebook graph API and have run into trouble regarding handling failed requests.
I use this code to create a new post
SocialFacebook.createPosting = function(data) {
var options = {
params: {
access_token : data.tokens.accessToken,
message : data.text
}
};
var url = 'https://graph.facebook.com/' + data.graphId + '/feed';
var response = HTTP.call('POST', url, options).data;
return response;
}
But instead of returning a JS object with error information in the response, it throws an error on failed requests
Exception while invoking method 'createPosting' Error: failed [500] {"error":{"message":"Duplicate status message","type":"FacebookApiException","code":506,"error_subcode":1455006,"is_transient":false,"error_user_title":"Duplicate Status Update","error_user_msg":"This status update is identical to the last one you posted. Try posting something different, or delete your previous update."}}
Because it's wrapped in an Error, the otherwise JSON object is now a string with some other stuff appended to it, which makes it difficult to parse and extract the attributes
Any idea as to why it throws an error, instead of returning a JS object with error details like usually?
Much appreciated
According to the docs, about HTTP.call():
On the server, this function can be run either synchronously or asynchronously. If the callback is omitted, it runs synchronously and the results are returned once the request completes successfully. If the request was not successful, an error is thrown.
So there you have it: since you called HTTP.call() synchronously (without providing a callback), if it responds with an error (in your case, Code 500) the error is thrown and not included in the data.

why is my grails integration testing of my web api failing?

I am developing an app that appends all the values of the form to a FormData() object e.g. "msgBody" and sends it to the grails server-side where it is consumed by jax-rs api. I have used something like:
GrailsWebRequest request = WebUtils.retrieveGrailsWebRequest()
def params = request.getParams()
if (!(params.msgBody.length() > 0)) {
log.error("Empty message body")
}
The problem I am having is with the integration testing of that api where I have written:
def headers = ['Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryZ7dAiucrA3eTbjzI', 'Accept': 'application/json']
def content='{"msgBody":"Hello World"}'
sendRequest("/api/v1/message", 'POST', headers, content.bytes)
I keep on getting the "500 Internal Server Error" and error message:
"Caused by: java.lang.NullPointerException: Cannot invoke method length() on null object".
Why is this happening?
I have found out that you don't need to set the Content-Type in the headers and you also have to set all the fields of the FormData() object even if they are null. I did so but still I am getting the same NullPointerException message.

How to handle 404 errors using webdriver code

Could you please help us how to handle 404 errors using WebDriver code?
Since you haven't provided enough information, I'm assuming that you want to check if request results into 404 then raise an error or display some message.
In following code, I'm requesting for 'Search' link on 'http://www.google.com':
require 'selenium-webdriver'
require 'open-uri'
driver = Selenium::WebDriver.for :firefox
driver.get "http://www.google.com"
search_link = driver.find_element(:link, "Search").attribute("href")
io = open search_link
status = io.status
if status == ["404", "Not Found"]
puts "Request is resulting into 404"
end
Let me know this is what you're looking for or not.
There are multiple ways (using Java), for a URL such as https://www.google.com/sdfsdsdfs :
String actualTitle = driver.getTitle();
assertEquals(actualTitle, "Error 404 (Not Found)!!1" );
or
String pageSource = driver.getPageSource();
if ( pageSource.contains("404") ) assertTrue(true, "404 not found error." );

com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure

com.thoughtworks.selenium.SeleniumException: ERROR: Command execution failure. Please search the user group at https://groups.google.com/forum/#!forum/selenium-users for error details from the log window. The error message is: Object doesn't support property or method 'createEvent'
I am getting the above error, somebody please help me out on this issue.
Help will be appreciated.
SeleniumServer server = new SeleniumServer(rcc);
DefaultSelenium selenium = new DefaultSelenium("localhost", 1212, "*iexploreproxy", "http://");
server.start();
selenium.start();
selenium.windowMaximize();
selenium.open("URL");
selenium.waitForPageToLoad("25000");
selenium.windowMaximize();
selenium.type("id=lgnLogin_UserName", "dy4cl");
selenium.type("id=lgnLogin_Password", "Test1234");
selenium.click("lgnLogin_LoginButton");
selenium.waitForPageToLoad("10000");
String msg = selenium.getText("//table[#id='lgnLogin']/tbody/tr/td/table/tbody/tr[4]/td");
System.out.println(msg);
Upgrade your Selenium Server file to 2.32.0. you can download it from here
Let me know if you are still facing the same issue.

Resources