Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to connect diagnosis #231

Closed
billmeek opened this issue Jan 21, 2017 · 26 comments
Closed

Failure to connect diagnosis #231

billmeek opened this issue Jan 21, 2017 · 26 comments
Assignees
Milestone

Comments

@billmeek
Copy link
Contributor

billmeek commented Jan 21, 2017

Comments (some nasty) of the app say that if the app
can't connect to the backend, there's no way to tell
what's wrong.

Would a solution be to check the individual parts of
the connection, e.g.

  • The tablet/phone has Wi-Fi turned on, not in airplane mode etc.
  • The backend can be reached, a la ping
  • Port 6544 is open
  • The API is working, Myth/GetHostName (I know this used to be done)
@billmeek billmeek added this to the 3.0.2 milestone Jan 21, 2017
@dmfrey
Copy link
Contributor

dmfrey commented Jan 21, 2017 via email

@billmeek
Copy link
Contributor Author

I found this for the device itself:
https://developer.android.com/training/monitoring-device-state/connectivity-monitoring.html

There seems to be a ping in /system:
http://stackoverflow.com/questions/3905358/how-to-ping-external-ip-from-java-android

I use nmap -p 6544 backendName to see if the port is
even there (from the shell.)

I was think along the lines of a verbose description of any
failure, e.g.

Please turn on your Wi-Fi on this device.

or

Unable to connect to the backend, see if it's running and/or
check the backend logs. A simple test is to access the backend
Services API from a browser on this device. Try:

IP/hostFromSettings:6544/Myth/GetHostName

etc.

@dmfrey
Copy link
Contributor

dmfrey commented Jan 21, 2017 via email

@dmfrey
Copy link
Contributor

dmfrey commented Jan 21, 2017

The app is already doing network connectivity checks. Take a look at this code. It is being done in a few places and I should really clean that up so there is only ever a single instance of this code.

isThereInternetConnection()

dmfrey added a commit that referenced this issue Jan 21, 2017
@dmfrey
Copy link
Contributor

dmfrey commented Jan 21, 2017

@billmeek I am not sure a ping is needed, so long as we react to connection failures appropriately. The SnackBar can contain an OnClickHandler. So maybe we make the network connection SnackBar contain a Troubleshoot link that lets us call all of these on one screen. So we could list the result of the ping on one line, along with the test name and a red or green dot to show if it passed or not. We could call the /Myth/GetHostName and display it in the same way.

We could use this as a common place to display all these tests.

@billmeek
Copy link
Contributor Author

Simple version of what follows:

  • is Wi-Fi on
  • is the backend's host up
  • is the Services API available

Found ICMP on this page, may help:
https://developer.android.com/reference/java/net/InetAddress.html#isReachable(int)
I like ICMP (ping) because it's just testing to see if the host is there. No port
required. It wouldn't need to be done all the time, just when troubleshooting
(e.g keep the existing isThereInternetConnection() and just drill down if
required.) I'm thinking isThereInternetConnection is testing the phone/tablet's
access to Wi-Fi.

Things like firewalls/port filtering may be in the way. The address
could appear in the SnackBar for all diagnostics. Ideally, the host
name if used in settings and always the IP, which could be IPv4 or 6.

I really like the idea of a Troubleshoot link.

Something like: if isThereInternetConnection() fails and Troubleshoot is
selected, then do the sReachable() followed by Myth/GetHostName to
verify that the Sevices API is fully available.

dmfrey added a commit that referenced this issue Jan 22, 2017
The troubleshootter is accessible from the navigation drawer, from the menu when viewing a media item details, or from a snackbar whenever a connection issue is reported.

Changes #231
@dmfrey
Copy link
Contributor

dmfrey commented Jan 22, 2017

@billmeek checkout the branch feature/issue_231_connectivity_check and give it a look. You can access the troubleshooter from the navigation drawer, the overflow menu on a video or recording, or anytime a SnackBar shows a connection failure. I think it still needs a little cleanup, but I think it is in line with what you were thinking.

@billmeek
Copy link
Contributor Author

Looking good! Recording right now, so only tested the 1st 2, plus I
mangled the hostname and that fails as expected.

dmfrey added a commit that referenced this issue Jan 22, 2017
@dmfrey
Copy link
Contributor

dmfrey commented Jan 22, 2017

@billmeek should we also add checks that we can parse recordings, upcoming recordings, encoders and videos?

@billmeek
Copy link
Contributor Author

That could be good, not a connection problem, but a configuration one.

One user had: LANG="en_US.ISO-8859-1" rather than en_US.UTF-8
(actually, it was German) that caused a parser to fail.

There's another way to test LANG: http://mc0:6544/Myth/GetBackendInfo
once JSON parsing is known to be OK.

<BackendInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" serializerVersion="1.1">
<Build>
<Version>v29-pre-194-g2a1ccc0</Version>
<LibX264>true</LibX264>
<LibDNS_SD>true</LibDNS_SD>
</Build>
<Env>
<LANG>en_US.UTF-8</LANG>
<LCALL>en_US.UTF-8</LCALL>
<LCCTYPE>en_US.UTF-8</LCCTYPE>
<HOME>/home/mythtv</HOME>
<MYTHCONFDIR/>
</Env>
<Log>
<LogArgs>
--verbose general --logpath /var/log/mythtv --loglevel info --quiet
</LogArgs>
</Log>
</BackendInfo>

I should retest that in 3.0.1. (recording right now, again.)

dmfrey added a commit that referenced this issue Jan 23, 2017
MythTV uses UTF-8. It has previously been reported by users that they were having difficulting displaying the data and the result was their character encoding was not in UTF-8. This will help to diagnose this issue.

Fixes #231
@dmfrey
Copy link
Contributor

dmfrey commented Jan 24, 2017

i should probably add a check in here for minimum mythtv version too. Thought?

dmfrey added a commit that referenced this issue Jan 24, 2017
@billmeek
Copy link
Contributor Author

The version test makes sense to me. And it works with
v29-pre.

The text on the Troublesheeo Connection page that reads:
"Airplane Mode is on" should be off. I'll push that (the icon
is correct.)

@dmfrey
Copy link
Contributor

dmfrey commented Jan 24, 2017

Cool. Anything more with this. I was thinking about the tests to parse the json for recordings, upcoming, videos and encoders. We should be handling all the parsing errors with #68 so I don't think we will need to put that here. We should probably keep it to 1 screen.

@billmeek
Copy link
Contributor Author

I like the existing screen, all the tests fit on a single
page of my Nexus 7.

Maybe all the text should just say what the test is
doing and let the icon reflect the state. I know that
if I enter the Airplane mode now, the text doesn't
change. Are you OK with letting the icons tell the
story?

@dmfrey
Copy link
Contributor

dmfrey commented Jan 24, 2017

Yes, that should be fine. Feel free to reword them. Keep them short enough to fit on one line.

@dmfrey
Copy link
Contributor

dmfrey commented Jan 24, 2017

just got the updates. gonna merge this into develop unless there are other outstanding requests

@billmeek
Copy link
Contributor Author

I do have some changes to the text, but won't be able to get to
it 'til later today.

@dmfrey
Copy link
Contributor

dmfrey commented Jan 24, 2017 via email

@billmeek
Copy link
Contributor Author

With troubleshooting, the app gets a fatal exception when it
tries to use GetBackendInfo for a version that doesn't have
the GetBackendInfo endpoint (< 0.28.)

curl -H Accept:"application/json" mc4:2744/Myth/GetBackendInfo
<?xml version="1.0" encoding="utf-8"?><detail><errorCode>401</errorCode><errorDescription>Invalid Action</errorDescription></detail>

Sent the above to my 0.27 backend (that's why the port above is 2744.)

From LogCat when the app does it:

01-24 20:01:28.090 24202-24377/org.mythtv.android D/OkHttp: <-- 404 Not Found http://192.168.1.224:2744/Myth/GetBackendInfo (47ms)
01-24 20:01:28.090 24202-24377/org.mythtv.android D/OkHttp: Date: 25 Jan 2017 02:01:30
01-24 20:01:28.090 24202-24377/org.mythtv.android D/OkHttp: Server: Linux 4.4.0-31-generic, UPnP/1.0, MythTV 0.27.20151025-1
01-24 20:01:28.090 24202-24377/org.mythtv.android D/OkHttp: Accept-Ranges: bytes
01-24 20:01:28.090 24202-24377/org.mythtv.android D/OkHttp: Connection: Keep-Alive
01-24 20:01:28.091 24202-24377/org.mythtv.android D/OkHttp: Content-Type: text/html; charset="UTF-8"
01-24 20:01:28.091 24202-24377/org.mythtv.android D/OkHttp: <-- END HTTP
01-24 20:01:28.092 24202-24377/org.mythtv.android D/TroubleshootActivity: doInBackground : result=okhttp3.ResponseBody$BomAwareReader@e73b3b3
01-24 20:01:28.101 24202-24377/org.mythtv.android E/UncaughtException: java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                           at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                           at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                           at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                           at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                           at java.lang.Thread.run(Thread.java:818)
                                                                        Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $
                                                                           at com.google.gson.JsonParser.parse(JsonParser.java:65)
                                                                           at org.mythtv.android.data.entity.mapper.BackendVersionJsonMapper.transformString(BackendVersionJsonMapper.java:50)
                                                                           at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:503)
                                                                           at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:485)
                                                                           at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                           at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                           at java.lang.Thread.run(Thread.java:818) 
                                                                        Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $
                                                                           at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559)
                                                                           at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1401)
                                                                           at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
                                                                           at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
                                                                           at com.google.gson.JsonParser.parse(JsonParser.java:60)
                                                                           at org.mythtv.android.data.entity.mapper.BackendVersionJsonMapper.transformString(BackendVersionJsonMapper.java:50) 
                                                                           at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:503) 
                                                                           at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:485) 
                                                                           at android.os.AsyncTask$2.call(AsyncTask.java:295) 
                                                                           at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                                                                           at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                           at java.lang.Thread.run(Thread.java:818) 
01-24 20:01:28.117 24202-24294/org.mythtv.android D/FA: Event not sent since app measurement is disabled
01-24 20:01:28.150 24202-24208/org.mythtv.android W/art: Suspending all threads took: 6.652ms
                                                         
                                                         --------- beginning of crash
01-24 20:01:28.432 24202-24377/org.mythtv.android E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
                                                                    Process: org.mythtv.android, PID: 24202
                                                                    java.lang.RuntimeException: An error occurred while executing doInBackground()
                                                                        at android.os.AsyncTask$3.done(AsyncTask.java:309)
                                                                        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
                                                                        at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:242)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                        at java.lang.Thread.run(Thread.java:818)
                                                                     Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $
                                                                        at com.google.gson.JsonParser.parse(JsonParser.java:65)
                                                                        at org.mythtv.android.data.entity.mapper.BackendVersionJsonMapper.transformString(BackendVersionJsonMapper.java:50)
                                                                        at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:503)
                                                                        at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:485)
                                                                        at android.os.AsyncTask$2.call(AsyncTask.java:295)
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                        at java.lang.Thread.run(Thread.java:818) 
                                                                     Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $
                                                                        at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559)
                                                                        at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1401)
                                                                        at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:542)
                                                                        at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
                                                                        at com.google.gson.JsonParser.parse(JsonParser.java:60)
                                                                        at org.mythtv.android.data.entity.mapper.BackendVersionJsonMapper.transformString(BackendVersionJsonMapper.java:50) 
                                                                        at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:503) 
                                                                        at org.mythtv.android.presentation.view.activity.phone.TroubleshootActivity$BackendVersionVerificationAsyncTask.doInBackground(TroubleshootActivity.java:485) 
                                                                        at android.os.AsyncTask$2.call(AsyncTask.java:295) 
                                                                        at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                                                                        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
                                                                        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 

@dmfrey
Copy link
Contributor

dmfrey commented Jan 25, 2017 via email

@billmeek
Copy link
Contributor Author

Unfortunately, it's an old MythTV issue. When the error fires, the response is
in XML, even though curl -H Accept:"application/json" mc4:2744/Myth/GetBackendInfo
was sent. If that endpoint existed in 0.27, then the response would have been in json.

@billmeek
Copy link
Contributor Author

@dmfrey, just pushed some new text. All remain on a
single line on my tablet in both landscape and portrait
modes.

@dmfrey dmfrey closed this as completed in 1cdbbc3 Jan 25, 2017
@dmfrey
Copy link
Contributor

dmfrey commented Jan 26, 2017

Reopening to address where /Myth/GetBackendInfo does not exist, but returns XML instead of JSON

dmfrey added a commit that referenced this issue Jan 26, 2017
@billmeek
Copy link
Contributor Author

@dmfrey, I could open a new issue if you like. Rather than
this specific case, a generic case for XML coming back when
JSON is requested. I haven't found the MythTV ticket yet, but
do remember reading one. Out of my league and would only
be fixed in master since it could affect existing API clients in
my opinion.

@billmeek billmeek reopened this Jan 26, 2017
dmfrey added a commit that referenced this issue Jan 26, 2017
@dmfrey
Copy link
Contributor

dmfrey commented Jan 26, 2017

Na, after looking at the stacktrace you posted, it looks like all I needed was another exception handler. Can you test it again with the latest commit?

@billmeek
Copy link
Contributor Author

That looks like the fix. Now the Troubleshooter correctly fails
because the backend isn't 0.28 or later. The UTF-8 check
remains gray, because that test isn't reached, which is good.

All of the tests have been tested. The last one was LANG="en_US.ISO-8859-1"
in the backend and the UTF-8 test failed, as it should.

Closing.

dmfrey added a commit that referenced this issue Jan 26, 2017
* prepare for 2.0.3

* Bugfix/issue 122 (#133)

* fixes #122

added back legacy attributes for older android sdk

* fixes #128

* fixes #122

* Fixes #122

* fixes #135 (#136)

* Update versions for release

* Update screenshots for release

* Update changelog for release

* Update version for release

* Update resources for release

* german translation of 2.1.1 changelog (#183)

* Fix search results on Android TV

Search results were failing to render due to not having the
appropriate leanback theme applied to the search results
activity. Once reapplied, it was found that search results
were not unique. Fixing how the search result db cleaned up
the existing entries resolved this. The latest leanback support
library was also applied, as was setting the search button
color to the defined accent color. Also, a merge issue was
identified which prevented search history from displaying and
was resolved.

fixes #184

* Prepare for release

* Prepare for release

* Prepare for release v2.2.1

* Update versions for release

changes #210

* Update screenshots and changelog for release

changes #210

* Update build options for release

changes #210

* Prepare for release

* Prepare for release

* Refactor duplicate code to a common base class

Changes #231

* Add Connection Troubleshooter

The troubleshootter is accessible from the navigation drawer, from the menu when viewing a media item details, or from a snackbar whenever a connection issue is reported.

Changes #231

* Add timing delays and animations to indicate progress

Changes #68

* Add timing delays and animations to indicate progress

Changes #231

* Add Backend Language Verification

MythTV uses UTF-8. It has previously been reported by users that they were having difficulting displaying the data and the result was their character encoding was not in UTF-8. This will help to diagnose this issue.

Fixes #231

* Add minimum mythtv version check

Changes #231

* Update Airplane Mode text

* Reword Troubleshooting text (again.)

* Add JsonSyntexException handler for old versions of MythTV that do not have this url

Fixes #231

* Add JsonSyntexException handler for old versions of MythTV that do not have this url

Fixes #231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants