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

Wallabag service not found #292

Closed
vasbinde opened this issue Sep 15, 2016 · 20 comments
Closed

Wallabag service not found #292

vasbinde opened this issue Sep 15, 2016 · 20 comments

Comments

@vasbinde
Copy link

Hi there,

I am attempting to connect to my wallabag service hosted on my Apache web server. This wallabag instance is v2. It functions properly when connecting through a web browser.

However, when connecting via the Android app, I consistently get the error, "Fail Wallabag service not found; check URL. Error code: 1"

I have tried multiple variants of the URL that the web browser works with; none work with the Android app.

Any suggestions?

@di72nn
Copy link
Member

di72nn commented Sep 15, 2016

That's weird. Can you post the URL? If you don't want to post it, you may check whether /login_check" method="post" name="loginform"> is present in the login page source code (in a web browser) - that's essentially how the app detects wallabag instance.

@ChristianAE
Copy link

This seems to be related to ticket #333.

I have a similar setup. The line login_check" method="post" name="loginform"> is present in the source code of my login page.

@di72nn
Copy link
Member

di72nn commented Oct 21, 2016

@ChristianAE
Does the source have a leading slash in this line too?

I forgot to mention the line alt="wallabag logo" /> that is also need to be present in the source code of the login page.

@ChristianAE
Copy link

Both are present:
<div class="center"><img src="/bundles/wallabagcore/themes/_global/img/logo-other_themes.png" alt="wallabag logo" /></div> <form action="/login_check" method="post" name="loginform">

@ChristianAE
Copy link

Some additional info: I am running wallabag in a Docker container. The container maps the internal port 80 to 9990.
When on the local network and connecting to http://HOSTNAME:9990 from the app it works.

From the outside I'm accessing the app using a proxy. This is my virtual host configuration for the proxy (I removed parts not relevant (i.e. SSL certificates)):

ServerName wallabag.myaddress.com SSLProxyEngine On SSLProxyVerify None SSLProxyCheckPeerCN Off SSLProxyCheckPeerName Off ProxyPreserveHost On ProxyPass / http://127.0.0.1:9990/ ProxyPassReverse / http://127.0.0.1:9990/

@di72nn
Copy link
Member

di72nn commented Oct 21, 2016

Will you be able to get logcat output from your device if I provide an APK with more verbose logging?

@ChristianAE
Copy link

I already created a fork.
I'll setup the project later and will dig into it. This way I can debug it against my server.

As far as I can tell the isLoginPage(...)-Method in WallabagServiceEndpointV2 is responsible to determine if it is a valid endpoint.
I'll probably find time to do it tonight or tomorrow.

Anything special I need to be aware of when setting up the project in Android Studio?

@di72nn
Copy link
Member

di72nn commented Oct 21, 2016

You are most likely interested in the content of the body variable (also maybe response.code()) before return ConnectionTestResult.WallabagNotFound;.

I just pushed a branch with logging added to the testConnection() method, that should print the aforementioned values in the logcat.

"Import project..." in Android Studio should work fine.

@ChristianAE
Copy link

I debugged the branch you provided. As far as I can tell the problem is related to a redirect happening when doing the test of the connection.

When examining the response object I have the following attributes:

Pay close attention to the request parameter. While on priorResponse it uses https, in the second it uses http. I am not sure if this is related to it. When opening the http URL in the browser it redirects me to the https version. Same happens when doing a GET request with Postman.

Here is the log output:

D/OkHttp: Sending request https://wallabag.MYDOMAIN.ddns.net/ on null
D/OkHttp: Received response for http://wallabag.MYDOMAIN.ddns.net/login in 220.8ms, status 404
      Server: 
      Date: Fri, 21 Oct 2016 14:23:46 GMT
      Connection: keep-alive
      Keep-Alive: timeout=60, max=2000
      Content-Type: text/html
      Content-length: 126
I/art: Do partial code cache collection, code=122KB, data=104KB
I/art: After code cache collection, code=122KB, data=104KB
I/art: Increasing code cache capacity to 512KB
I/WallabagServiceEndpointV2: testConnection() expected login page, got unknown response
I/WallabagServiceEndpointV2: testConnection() response code: 404
I/WallabagServiceEndpointV2: testConnection() response body: <HTML><HEAD><TITLE>Document Error: Not Found</TITLE></HEAD>
                         <BODY><H2>Access Error: 404 -- Not Found</H2>
                         </BODY></HTML>
D/TestConnectionTask: Connection test result: WallabagNotFound

@ChristianAE
Copy link

The problem is the redirect!

The Method okhttp3.internal.http.RetryAndFollowUpInterceptor#followUpRequest handles what happens in case of code 302. It extracts the "Location" from the header. In my case this is the http-URL.
What I don't understand is, why this is than not redirected to the https equivalent.

@ChristianAE
Copy link

I solved the problem by adding Header edit Location ^http: https: to the apache VirtualHost config.

This way the redirect uses https. I am not sure if this is the intended way.

It seems odd to me that OkHttp "decides" to downgrade the connection to the unsafer http.

Nevertheless @di72nn thank you for you effort and patience!

@di72nn
Copy link
Member

di72nn commented Oct 21, 2016

I'm glad you resolved it. And thank you for the details.

@di72nn di72nn changed the title Using the latest Wallabag for Android - Wallabag service not found Wallabag service not found Oct 21, 2016
@di72nn
Copy link
Member

di72nn commented Nov 30, 2016

Please reopen if you can reproduce the problem with the latest app version.

@rototom
Copy link

rototom commented May 5, 2017

Seems, I have the same problem with my installation.
Wallabag is installed in wallabag.pknr.de and works fine in browser.
Apache logs:

176.199.249.188 - - [05/May/2017:23:39:44 +0200] "GET /login HTTP/1.1" 200 1673 "-" "okhttp/3.6.0"
176.199.249.188 - - [05/May/2017:23:39:44 +0200] "GET / HTTP/1.1" 302 4358 "-" "okhttp/3.6.0"
176.199.249.188 - - [05/May/2017:23:39:44 +0200] "GET /login HTTP/1.1" 200 1761 "-" "okhttp/3.6.0"

Redirect in vhost.conf:
<IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php [QSA,L] Header edit Location ^http: https: </IfModule>

@di72nn
Copy link
Member

di72nn commented May 6, 2017

@rototom seems good to me. If it still doesn't work for you, can you open a new issue and provide more info (like what you do and which error message you get)?

@koenvervloesem
Copy link

koenvervloesem commented Sep 14, 2017

I seem to have a similar problem. The connection test of the Android app fails with "Connection test failed: Unknown page after login" on my self-hosted Wallabag instance. In /var/log/apache2/wallabag_access.log I see:

109.140.128.45 - - [14/Sep/2017:12:47:38 +0200] "GET / HTTP/1.1" 302 3959 "-" "okhttp/3.8.1"
109.140.128.45 - - [14/Sep/2017:12:47:38 +0200] "GET /login HTTP/1.1" 200 1558 "-" "okhttp/3.8.1"
109.140.128.45 - - [14/Sep/2017:12:47:38 +0200] "POST /login_check HTTP/1.1" 302 848 "-" "okhttp/3.8.1"
109.140.128.45 - - [14/Sep/2017:12:47:38 +0200] "GET / HTTP/1.1" 200 1454 "-" "okhttp/3.8.1"
109.140.128.45 - - [14/Sep/2017:12:47:38 +0200] "GET / HTTP/1.1" 200 1454 "-" "okhttp/3.8.1"

By the way, is it normal that if I visit the /login_check page in my browser, I get a "405 Method Not Allowed" http error?

I have a vhost file such as in https://doc.wallabag.org/en/admin/installation/virtualhosts.html, but I'm running an https version too with Let's Encrypt and this added a rewrite rule to redirect http requests to https, so I'm always using https:

RewriteCond %{SERVER_NAME} =wallabag.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

I tried adding Header edit Location ^http: https: such as ChristianAE suggested, but this didn't change my connection problem.

@di72nn
Copy link
Member

di72nn commented Sep 14, 2017

109.140.128.45 - - [14/Sep/2017:12:47:38 +0200] "GET / HTTP/1.1" 200 1454 "-" "okhttp/3.8.1"
1454 is a very suspicious response size (I believe the response should be larger).

Please state your wallabag server version, installation method, and Android app version.

You can try to enter incorrect password in the app and see whether it shows a different error (something like "incorrect username or password").

@koenvervloesem
Copy link

I installed Wallabag from Git, here is what I did: https://community.wallabag.org/t/blank-page-after-installation-permission-denied-errors/87/4 (that problem is already solved).

Wallabag server version: 2.2.3
Wallabag Android app version: 2.0.1 (105)

When I enter an incorrect username and password, I get another error message indeed: "Can't login - check username and password".

@di72nn
Copy link
Member

di72nn commented Sep 14, 2017

I take it you have no problem logging in with a desktop web browser, right? Can you do it (log in) and show the apache log fragment that contains "POST /login_check... line and a couple of following lines?

@koenvervloesem
Copy link

Well, the Android app suddenly suddenly works now. But I was running a Redis worker for importing my Pocket articles. Maybe the load was too much for my server and the app got a timeout? At least it's sorted out now.

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

5 participants