Daskiworks / ghwatch

This app for Android allows you to follow GitHub notifications directly from your device.
Apache License 2.0
25 stars 7 forks source link

Connection Problems due to Github https protocol settings changes #108

Open Knorrke opened 6 years ago

Knorrke commented 6 years ago

Hey, first of all thanks for the great tool, helps me a lot to stay in touch. Unfortunately I get connection errors recently (~1 week or so). Just wondering if anyone else has the same problems?

Error displayed:

Communication with GitHub server failed due network error. Try later please. Displayed data may be outdated!

I'm on Android 4.2.2, GH:watch version 1.25

velias commented 6 years ago

Hi, I do not have any other reports of this problem. Theoretically you can hit github API request limit if you perform calls against Github API from other app or system also under your account. I'm not fully sure how GH::watch reports this problem. You can visit Settings -> GitHub API request info to see if this is the problem.

Knorrke commented 6 years ago

Thanks for the reply! Unfortunately I don't think that's causing the issue, it says there are 4999 API calls left (though this number didn't change with reloading?). I attached a Screenshot below: screenshot_2018-03-13-07-58-22

I tried reinstalling the app but now am stuck on the login screen. Still receiving the same error when trying to connect to my account. Any other idea how I can track whats causing this? Is there a way to log more stuff, e.g. when I build the app myself?

velias commented 6 years ago

I believe app writes more detailed info about the error into common android log. It should definitely help if you can look there.

kkm000 commented 6 years ago

Hi @velias, I am having exactly same problem. Android 6.0.1, phone model CAT S60. The app stopped popping up notifications a few weeks ago, I believe about the same time as for @Knorrke. I checked the rate limit, and it is also above 4900 requests remaining, so this is not a rate-limiting issue. I also removed all application's data (Android's Settings/Apps/../Storage, then Clear cache and Clear Data buttons). When I started the app again, I logged on successfully, but the Unread notifications screen is empty. Watched Repositories is populated, however, so this is only the notifications that are not shown.

My paid settings. such as Show Labels, disappeared with the data cleaning, too. I'd be happy to drop a few more coins in the jar :smiley:, I like the app so much, but some people could complain, so this is also worth fixing somehow.

I believe app writes more detailed info about the error into common android log. It should definitely help if you can look there.

Where? I know so little about Android, sorry. But I can install the SDK and connect over USB if you want me to help track this issue down. I'm recalling doing that a few years ago when pulling diagnostics for another developer. Anything I can do? My phone is not rooted, but I have developer features enabled.

EDIT: found the "restore donation" button, paid settings restored. But I sent you a coffee anyway, because I suspect you'll need it!!!

kkm000 commented 6 years ago

Another thing I just noticed. My error message is different, Communication with GitHub server failed due network error, not "unknown error" as that of @velias.

nit: "to" is missing in the error message: Communication with GitHub server failed due to network error.

Knorrke commented 6 years ago

It's the same error though, right? It's network error on mine too. I tried viewing the logs with logcat, but couldn't find anything (probably because I didn't understand much of the logged stuff...). I welcome any help I can get in that matter :)

Also as a side note: I can't even log in since deleting the data and reinstalling the app, so might still be a different issue?

velias commented 6 years ago

@kkm000 @Knorrke thanks for your support.

Maybe I can extend the app to log info about communication problems to some file on device storage, WDYT? In android Logcat you should look for string containing "loading failed due connection problem", it should be on WARN level.

Regarding real cause of the problem, can you correlate start of the problems with some action like:

velias commented 6 years ago

New app version with error logging capability has been released. Hopefully it will help to find cause of yours problems.

Knorrke commented 6 years ago

Thanks for your help @velias! I can't access the settings, since I'm stuck at the login screen, though. But I looked at the logcat output again and now found this error, when trying to connect: W/AuthenticationManager: Login failed due to connection problem: No peer certificate hope this helps!

Edit: By searching for the error I found, that most of the times it's caused by incorrect time/date settings. However it was already on automatic on my device.

velias commented 6 years ago

@Knorrke looks like the error generally means that your phone is not able to establish secure SSL connection with the github server, eg because not able to validate servers certificate or other problem in SSL handshake. I think it may be related to this change in github server settings https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/

Unfortunatelly I can hardly do anything with this from the app, I use standard Android APIs, the problem is incompatibility between github server and your android probably :-(

velias commented 6 years ago

The Android documentation for SSLSocket says that TLS 1.1 and TLS 1.2 is supported within android starting API level 16+ (Android 4.1, Jelly Bean). But it is by default disabled but starting with API level 20+ (Android 4.4 for watch, Kitkat Watch and Android 5.0 for phone, Lollipop) they are enabled. But it is very hard to find any trustworthy documentation about how to enable it for phones running 4.1 for example :-(

Knorrke commented 6 years ago

Ok @velias, thanks for your efforts! That sounds like the cause at least to my issue. Since @kkm000 is on Android 6.0 that might be something else.

I might take a look at the code in the next weeks and see if I can get TLS 1.2 to run on my device. I'll let you now, if I manage to do so :-) Otherwise I think it makes sense to set the API-compatibility to level 20 then?

kkm000 commented 6 years ago

I turned on the new option, then in the Apps applet forced stop and cleared the cache, and restarted the app. The error is still there, occurred multiple times, but I do not see any log file. This is from adb shell:

shell@CatS60:/sdcard/Android/data/com.daskiworks.ghwatch $ ll -R

.:
drwxrwx--x u0_a164  sdcard_rw          2018-04-21 22:49 cache

./cache:
drwxrwx--x u0_a164  sdcard_rw          2018-04-21 22:50 inet_img

./cache/inet_img:
-rw-rw---- u0_a164  sdcard_rw    18854 2018-04-21 22:50 avatars2.githubusercontent.com-u-11650082%3Fv%3D4
-rw-rw---- u0_a164  sdcard_rw     4780 2018-04-21 22:50 avatars2.githubusercontent.com-u-6001315%3Fv%3D4
-rw-rw---- u0_a164  sdcard_rw    12738 2018-04-21 22:49 avatars3.githubusercontent.com-u-8228229%3Fv%3D4
shell@CatS60:/sdcard/Android/data/com.daskiworks.ghwatch $

The error occurs every time I switch between Watched Repositories and Unread Notifications, and also every 10 or 15 minutes if I keep the application open. I waited for a while hoping it will flush the log file or something, but no, the file just does not appear. The inet_img directory was creates as soon as I started the app.

Should I look somewhere in the system logs? But I do not know where. @Knorrke mentions logcat, but this flies over my head, sorry. I am not an Android dev at all.

kkm000 commented 6 years ago

Ah, there we go! After selecting "Unread Notifications" while currently on the "Watched Repositories" screen:

04-22 00:46:47.720 10280 10280 D ActivityBase: Intent fro drawer navigation : Intent { act=com.daskiworks.ghwatch.ACTION_RESET_FILTER cmp=com.daskiworks.ghwatch/.MainActivity } with action com.daskiworks.ghwatch.ACTION_RESET_FILTER
04-22 00:46:47.760 10280 10280 D MainActivity: onNewIntent() intent: Intent { flg=0x10000000 cmp=com.daskiworks.ghwatch/.MainActivity }
04-22 00:46:47.762 10280 10280 D MainActivity: onResume() intent: Intent { flg=0x10000000 cmp=com.daskiworks.ghwatch/.MainActivity }
04-22 00:46:47.796 10280 13003 D UnreadNotificationsSvc: Notification loading URL: https://api.github.com/notifications
04-22 00:46:47.797 10280 13003 D RemoteSystemClient: Going to perform GET request to https://api.github.com/notifications
04-22 00:46:47.802 10280 13003 D RemoteSystemClient: Set request header Accept-Encoding:gzip
04-22 00:46:47.803 10280 13003 I DpmTcmClient: RegisterTcmMonitor from: org.apache.http.impl.conn.TcmIdleTimerMonitor
04-22 00:46:48.556 10280 13003 D RemoteSystemClient: Response header X-RateLimit-Reset parsed: 1524384450000
04-22 00:46:48.556 10280 13003 D RemoteSystemClient: Response Link.next parsed: https://api.github.com/notifications?page=2
04-22 00:46:48.556 10280 13003 D RemoteSystemClient: Response http code: 200
04-22 00:46:48.556 10280 13003 D RemoteSystemClient: Response http code: 200
04-22 00:46:48.682 10280 13003 D RemoteSystemClient: Going to perform GET request to https://api.github.com/notifications?page=2
04-22 00:46:48.684 10280 13003 D RemoteSystemClient: Set request header Accept-Encoding:gzip
04-22 00:46:48.684 10280 13003 I DpmTcmClient: RegisterTcmMonitor from: org.apache.http.impl.conn.TcmIdleTimerMonitor
04-22 00:46:49.050 10280 13003 D RemoteSystemClient: Response header X-RateLimit-Reset parsed: 1524384450000
04-22 00:46:49.051 10280 13003 D RemoteSystemClient: Response Link.next parsed: <https://api.github.com/notifications?page=3
04-22 00:46:49.051 10280 13003 D RemoteSystemClient: Response http code: 200
04-22 00:46:49.051 10280 13003 D RemoteSystemClient: Response http code: 200
04-22 00:46:49.164 10280 13003 D RemoteSystemClient: Going to perform GET request to <https://api.github.com/notifications?page=3
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc: NotificationStream loading failed due to: Illegal character in scheme at index 0: <https://api.github.com/notifications?page=3
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc: java.net.URISyntaxException: Illegal character in scheme at index 0: <https://api.github.com/notifications?page=3
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.net.URI.validateScheme(URI.java:420)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.net.URI.parseURI(URI.java:364)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.net.URI.<init>(URI.java:205)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at com.daskiworks.ghwatch.backend.RemoteSystemClient.readInternetDataGet(RemoteSystemClient.java:214)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at com.daskiworks.ghwatch.backend.RemoteSystemClient.getJSONArrayFromUrl(RemoteSystemClient.java:174)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at com.daskiworks.ghwatch.backend.UnreadNotificationsService.readNotificationStreamFromServer(UnreadNotificationsService.java:471)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at com.daskiworks.ghwatch.backend.UnreadNotificationsService.getNotificationStreamForView(UnreadNotificationsService.java:151)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at com.daskiworks.ghwatch.MainActivity$DataLoaderTask.doInBackground(MainActivity.java:479)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at com.daskiworks.ghwatch.MainActivity$DataLoaderTask.doInBackground(MainActivity.java:462)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at android.os.AsyncTask$2.call(AsyncTask.java:295)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
04-22 00:46:49.165 10280 13003 E UnreadNotificationsSvc:        at java.lang.Thread.run(Thread.java:818)
04-22 00:46:49.174 10280 10280 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@71ef8fe
04-22 00:46:49.174 10280 10280 V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a81985f

Does this help at all?

kkm000 commented 6 years ago

Look at this

Response Link.next parsed: <https://api.github.com/notifications?page=3

and this

Going to perform GET request to <https://api.github.com/notifications?page=3

I suspect the extra < is the deal-breaker! Actually, I have a horrible lot of unread notifications (472, at the moment), so it might explain why other users do not hit this, if this is a paging issue.

Maybe it also makes sense to add a limiting option for the number of received notifications? I usually skim over the new ones in the pop-up. The majority comes from one single repo, and I am tracking their fast-paced development, but sometimes I do collect hundereds of unread notifications, and do not want to reset them. I can shrink the list by 100-150 in an hour, but I do not always have that hour :(

But I do that on a desktop only, naturally, and do not need all the 400+ in the app. I am using it only to check if I have more urgent ones.

kkm000 commented 6 years ago

Page 2 is the first one to contain both rel="prev" and rel="next", and possibly the first one to contain the comma. I suspect there is a space after the comma in the Link header, and your code assumes the string always starts with the <, and skips only one character.

And of course there has to be at least 3 pages worth of results to trigger the bug.

kkm000 commented 6 years ago

linkH.split("\\s*,\\s*") perhaps?

velias commented 6 years ago

@kkm000 thanks for the troubleshooting. I'll patch this problem in next version.

kkm000 commented 6 years ago

Thank you!