Android media player error status messages? - android

In my application, I am playing files from URL using MediaPlayer API.
It plays the remote file very well, the problem comes while handling errors,
1] When a file is not available on a remote URL (i.e. 404)
error message in IOExcpeiton reads, "Prepare failed.: status=0x1"
2] When the phone is not connected to internet exception message is same i.e.
"Prepare failed.: status=0x1"
How do we differentiate between 404 & no connectivity states for better handling of exceptions?
So far I have understood the IOException with the error message "Prepare failed.: status=0x1" appears only when a requested resource file or URL not available

For Error : Prepare failed.: status=0x1
Ref: Android MediaPlayer throwing "Prepare failed.: status=0x1" on 2.1, works on 2.2
I do not know if this is your issue, but I just found a solution to the problem the described by Tuszy above. I could read the file I was creating from external storage but not from Cache.
The solution is that the read write permissions when writing the file are different.
Please see this excellent explanation in this blog I found.
http://blog.weston-fl.com/android-mediaplayer-prepare-throws-status0x1-error1-2147483648/
Ref : Internet Connection Error
getting an UnknownHostException will mean that the application was
able to connect to the Internet
No it doesn't. It means the application was unable to resolve the host name. That could be because the host name doesn't exist, or because it was unable to connect to the Internet to resolve it.
When there is no Internet connection.
No specific exception. "There is no Internet connection" doesn't have a well-defined meaning. The condition resolves to one of the other failure modes below.
When the URL cannot be found.
If the host cannot be found, UnknownHostException. If the content part of the URL cannot be found, HTTP 404.
When the request timed out.
ConnectException with 'connection timed out' as the message, or SocketTimeoutException if it's a read timeout.
When the website is down.
ConnectException with 'connection refused' as the message.
When access is denied.
HTTP 403.

Related

React native video unable to play m3u8 file

Problem
I'm trying to stream a m3u8 file in a react native app (for android TV) and I'm getting this error:
LOG {"error": {"errorCode": "22004", "errorException": "com.google.android.exoplayer2.ExoPlaybackException: Source error", "errorStackTrace": "com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:632)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:604)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
at com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource.open(OkHttpDataSource.java:329)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:258)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:99)
at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:62)
at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:174)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:412)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
", "errorString": "ExoPlaybackException: ERROR_CODE_IO_BAD_HTTP_STATUS"}}
I don't know java so from the above traceback I'm guessing that the server is responding with an HTTP 403 and therefore it is unable to stream the file.
What I've tried
This one is not much of a solution but I tried switching to the react-native-video-player instead of react-native-video but that didn't work.
I tried passing the type: 'm3u8' and type: 'hls' inside the source attribute of the video tag along with the uri and this didn't help at all.
Tried to check if another m3u8 url (i.e. from another domain/server) is working, and it is working.
Downgrading react-native-video version, problem persists with different error message.
I decided to ssh into my android TV and directly use curl to fetch the m3u8 file and it responds with this:
curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
Moreover, many of the issues I found on github having a similar problem contain a URL that gives the same response when fetched directly with curl. Interestingly, if I use the fetch API in JS to console log the response from the m3u8 url, it works perfectly. So I'm guessing the problem is somewhere in exoplayer.
Specs
react-native : 'npm:react-native-tvos#0.69.6-0'
react-native-video : '^6.0.0-alpha.3'
Android TV : Tested both on a Raspberry Pi running Android TV (LineageOS I think) and an actual android tv set top box with same results.
The issue was with the user-agent header, exoplayer was setting a user-agent which was causing an HTTP 403. I had to use a proxy to figure this out and still have no clue as per why android studio was not showing the request that had an error.

Http failure response for xxx 0 Unknown Error

PostGraphile v4.9.2 server listening on port 5001
‣ GraphQL API: http://0.0.0.0:5001/graphql
how can i change http to https. i mean, i want https://0.0.0.0:5001/graphql
because, i am getting error while debugging my ionic capacitor app for android
E/Capacitor/Console: File: http://localhost/vendor-es2018.js - Line 41539 -
Msg: ERROR Error: Http failure response for http:// mydomain .com:5001/graphql: 0 Unknown Error
i think it is about http problem but as you see it is unknown error. Thanks in advance
i found the solution here: How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?
i allowed http requests in manifest.xml and i added networkSecurityConfig.xml
Thank you all

Android: Handle App Link Verification failure at install time

I added app link feature with autoVerify set for my app following link
On testing the app, it worked in the begining. Then after reinstalling the build, not working.
On debugging what I found is the response time for my .well-known/assetlinks.json file is > 1sec.
which gives timeout error on test-url https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://example.com&relation=delegate_permission/common.handle_all_urls
{
"maxAge": "599.999999353s",
"debugString": "********************* ERRORS *********************\n* Error: deadline_exceeded: Timeout occurred while fetching Web statements from https://example.com./.well-known/assetlinks.json (which is equivalent to 'https://example.com/.well-known/assetlinks.json') using download from the web (ID 1).\n********************* INFO MESSAGES *********************\n* Info: No statements were found that match your query\n"
}
Looks like because of this timeout, verification is failing.
I would like to know whether app/system retry verification at any point later if verification failed on install (may be because of connection issue or temporary website down)?
Unfortunately Android M does not automatically reattempt verification if it fails due to timeout or connectivity issues. As you found in this guide the next attempt will occur on app update or re-install.

XMPP messages lost on Android while switching data connectivity (e.g. turning Wifi of, GSM <-> Wifi switch)

I'm developing a chat application in android. Using XMPP server. PHP server has been migrated to ejabber.
My notification works properly in all scenarios. But in one case I am losing the XMPP messages. In fact I am not getting notifications.
In detail, I am turning off the WiFi or data connection. and after turning off WiFi or data connection any notification sent to me that is not getting. after when I turn ON the WiFi or data connection, I am not able to get the messages which were sent to me.
I have implemented service in background. that makes xmpp connection always live.
I getting this error while i turn OFF the WiFi connection.
java.net.SocketException: sendto failed: EPIPE (Broken pipe)
java.net.SocketException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:506)
at libcore.io.IoBridge.sendto(IoBridge.java:475)
at java.net.PlainSocketImpl.write(PlainSocketImpl.java:508)
at java.net.PlainSocketImpl.access$100(PlainSocketImpl.java:46)
at java.net.PlainSocketImpl$PlainSocketOutputStream.write(PlainSocketImpl.java:270)
at java.io.OutputStreamWriter.flushBytes(OutputStreamWriter.java:167)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:158)
at java.io.BufferedWriter.flush(BufferedWriter.java:124)
at org.jivesoftware.smack.PacketWriter.writePackets(PacketWriter.java:286)
at org.jivesoftware.smack.PacketWriter.access$12(PacketWriter.java:270)
at org.jivesoftware.smack.PacketWriter$1.run(PacketWriter.java:137)
Caused by: libcore.io.ErrnoException: sendto failed: EPIPE (Broken pipe)
at libcore.io.Posix.sendtoBytes(Native Method)
at libcore.io.Posix.sendto(Posix.java:146)
at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:177)
at libcore.io.IoBridge.sendto(IoBridge.java:473)
... 9 more
at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:552)
at libcore.io.IoBridge.recvfrom(IoBridge.java:516)
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:489)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:241)
at java.io.InputStreamReader.read(InputStreamReader.java:244)
at java.io.BufferedReader.read(BufferedReader.java:310)
at org.jivesoftware.smack.XMPPConnection$AliveReader.read(XMPPConnection.java:1122)
at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1496)
at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:979)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:346)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:321)
at org.jivesoftware.smack.PacketReader.access$1(PacketReader.java:216)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
Caused by: libcore.io.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
at libcore.io.Posix.recvfromBytes(Native Method)
at libcore.io.Posix.recvfrom(Posix.java:131)
at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
at libcore.io.IoBridge.recvfrom(IoBridge.java:513)
... 13 more
So to install mod_archive I need to do this, the typical:
Write following line in cmd. (For cent Os)
Login as root
Create new directory:
mkdir ejabberd_archive_plugin
cd ejabberd_archive_plugin
now get the latest ejabberd modules using following command
yum https://svn.process-one.net/ejabberd-modules
cd ejabberd-modules/mod_archive/trunk
./build.sh
Now go to ebin directory using following cmd and get the list of all *.beam files for ejabberd archive plugins.
root#ns1 [/ejabberd_archive_plugin/ejabberd-modules/mod_archive/trunk/ebin]# ls –l
Using following cmd you will get all ejabberd *.beam files list when ejabberd setup and configure.
root#ns1 [/usr/lib64/ejabberd/ebin]# ls -l
Now copy all *.beam (archive plugins) files to ejabberd ebin directory using following cmd
root#ns1 [/]# cp /ejabberd_archive_plugin/ejabberd-modules/mod_archive/trunk/ebin /usr/lib64/ejabberd/ebin
Now go to following URL and copy all sql table queries and run in phpmyadmin (ejabberd database)
https://svn.process-one.net/ejabberd-modules/mod_archive/trunk/src/mod_archive_odbc_mysql.sql
Now configure ejjaberd.cfg using following cmd
root#ns1 [/etc/ejabberd]# vi ejabberd.cfg
Add the following line into ejabberd.cfg file in modules configuration section
{mod_archive_odbc, [{database_type, "mysql"}, {default_auto_save, true}, {enforce_default_auto_save, true}]},
Now restart the ejabberd service.
root#ns1 [/etc/ejabberd]# sudo service ejabberd restart
You need "Stream Management" XEP-198 enabled connections to achieve this. Georg wrote a good blog entry about that topic: http://op-co.de/blog/posts/XEP-0198/
Basically it allows for stanza acknowledgement and stream resumption, which is exaclty what you want to do in case of e.g a Wifi <-> GSM switch.
I conclude from the stacktrace that you are using aSmack (which is Smack ported to Android). There is a open feature request to implement Stream Management in Smack: SMACK-333. In fact, i've recently started working on the implementation, but can't name an ETA.
You have to create the separate web service for that. so thus why we can handle the history of the sent message. we can manage the offline message.
XEP-198 is the only solution. make plugin for your server and make that easy to manage the remain message that is lose. there may be other solution but AFAIK, this would be the solution.
you can modify archive plugin to save message ids in it.
When user comes online call a web service with last message id received. server can get all the later messages saved on the server. I created it i the same way and working perfectly well.
You should relogin after reconnecting to the internet everytime. But, keep in mind that if you relogin with same resource and same user even it is online then server will throw stream error (replaced by new connection) which will make you offline & you won't receive any message. For this, disconnect yourself properly first before relogin. Try searching on mod Amp module.

Android SDK Manager - Failed to fetch

Error 1:
Failed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-2.xml, reason: Unknown Host www.google.de
Error 2:
Failed to fetch URL http://dl-ssl.google.com/android/repository/repository-10.xml, reason: IO Unknown Host www.google.de
Can I download and insert this xml files manually?
Are then this problems solved?
There are some people who has posted about downloading SDK tools without SDK manager.
Like in this site.
But you should check your internet connection. I have same problem but after that i came to know that it was because of bad internet connection.
I have retried it and it was downloaded successfully.
I encountered the same problem and here is what I did to solve the problem.
Since I use proxy server for accessing internet i have edited the file
"C:\Users\.AndroidStudio\config\options\other.xml" as
Notice the PROXY_HOST value there is no "http://" part, this is important. In my case when I insert that it did not work I did not know why.
2. I have edited the file
"C:\Users\\AppData\Local\Android\sdk\tools\android.bat"
I have changed the line at the end of android.bat file from
call "%java_exe% %REMOTE_DEBUG%" ....
to
call "%java_exe% **-Djava.net.preferIPv4Stack=true** %REMOTE_DEBUG%"...
Notice the value in bold

Categories

Resources