traccar / traccar-manager-android

Traccar Manager for Android
https://www.traccar.org/manager
Apache License 2.0
257 stars 369 forks source link

Manager app doesn't follow redirect from server #76

Open kobisamoray opened 4 years ago

kobisamoray commented 4 years ago

We have configured a HTTPS forwarder for our Traccar server. While configuring Traccar Manager for Android URL upon first execution, configuring the HTTPS URL works. However, configuring the HTTP URL, while relying on redirection by the HTTPS forwarder, results with a server error. Same configuration with the iPhone Traccar Manager app works well. Specifying the HTTP URL in Chrome for Android obviously works.

tananaev commented 4 years ago

You have to use proper proxy, not redirection.

kobisamoray commented 4 years ago

@tananaev I didn't explain my problem very well. Our Apache configuration is as described here: https://www.traccar.org/secure-connection/

So HTTPS listener is proxying the SSL requests locally to Traccar server as you advise. Additionally we have a redirector for non-secure requests from the HTTP outbound listener, to the HTTPS listener.

We do have users who their apps are configured to use the HTTP listener, but the Android app fails to follow the redirector and fails with an error instead. The iOS app behaves well in that case.

tananaev commented 4 years ago

If you proxied everything correctly and you have a valid SSL certificate, there should be no issues.

kobisamoray commented 4 years ago

SSL Cert is not the issue is this works in both iPhone and in a browser (including Android's). Tried debugging this a bit: seems like the following line receives the 302 message instead of the JSON object: https://github.com/traccar/traccar-manager-android/blob/master/app/src/main/java/org/traccar/manager/StartFragment.java#L80

That makes sense, as I guess that HttpURLConnection doesn't recourse the request while receiving 302

tananaev commented 4 years ago

So you are using redirect. Just use correct URL from the beginning.