Android Client 3.2.3 won't upload, but dev version does

Nextcloud version (eg, 12.0.2): 13.0.6
Operating system and version (eg, Ubuntu 17.04): Debian 8.11
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.10
PHP version (eg, 7.1): PHP 5.6.36

The issue you are facing:
Auto uploads and regular uploads do not work. I get a “Bad Gateway” error. When I try with the Dev version of the app, it works perfectly fine against the same server. The server is behind Cloud Flare, using their SSL certificates. I can browse via the web page, and manually copy files to it there. This is happening on multiple Android devices - a Samsung S8, and an Asus Zenfone 3

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. NC installed on server, client app installed on Android
  2. Snap a picture while in range of Wi-Fi, so the Auto-Upload script catches the photos
  3. Attempt to upload - failure

The output of your Nextcloud log in Admin > Logging:

2018/09/01 16:57:44
UploadListAdapter : loadUploadItemsFromDb

2018/09/01 16:57:44
FileUploader : Starting command with id 72

2018/09/01 16:57:44
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status=UPLOAD_IN_PROGRESS

2018/09/01 16:57:44
UploadsStorageManager : updateUpload returns with: 1 for file: /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg

2018/09/01 16:57:44
UploadsStorageManager : notifyObserversNow

2018/09/01 16:57:44
UploadListAdapter : loadUploadItemsFromDb

2018/09/01 16:57:44
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status:UPLOAD_IN_PROGRESS and result:UNKNOWN (old:/storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg status:UPLOAD_IN_PROGRESS result:-1)

2018/09/01 16:57:44
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status=UPLOAD_IN_PROGRESS

2018/09/01 16:57:44
UploadsStorageManager : updateUpload returns with: 1 for file: /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg

2018/09/01 16:57:44
UploadsStorageManager : notifyObserversNow

2018/09/01 16:57:44
UploadListAdapter : loadUploadItemsFromDb

2018/09/01 16:57:44
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status=UPLOAD_IN_PROGRESS

2018/09/01 16:57:44
UploadsStorageManager : updateUpload returns with: 1 for file: /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg

2018/09/01 16:57:44
UploadsStorageManager : notifyObserversNow

2018/09/01 16:57:44
UploadFileOperation : normal upload

2018/09/01 16:57:44
OwnCloudClient #78 : Creating OwnCloudClient

2018/09/01 16:57:44
AccountUtils : Restoring cookies for lukebarone@cloud.lukebarone.ca

2018/09/01 16:57:44
OwnCloudClient #78 : REQUEST GET /index.php/204

2018/09/01 16:57:45
UploadFileOperation : Checking name collision in server

2018/09/01 16:57:45
UploadFileOperation : Copying local file

2018/09/01 16:57:45
UploadFileOperation : Creating temporal folder

2018/09/01 16:57:45
UploadFileOperation : Creating temporal file

2018/09/01 16:57:45
UploadFileOperation : Copying file contents

2018/09/01 16:57:45
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status=UPLOAD_IN_PROGRESS

2018/09/01 16:57:45
UploadsStorageManager : updateUpload returns with: 1 for file: /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg

2018/09/01 16:57:45
UploadsStorageManager : notifyObserversNow

2018/09/01 16:57:45
OwnCloudClient #0 : REQUEST PUT /remote.php/webdav/Photos//2018/08/P_20180826_190241_vHDR_Auto.jpg-chunking-1364505336-4-0

2018/09/01 16:57:47
RemoteOperationResult : RemoteOperationResult has processed UNHANDLED_HTTP_CODE: 502 Bad Gateway

2018/09/01 16:57:47
ChunkedUploadRemoteFileOperation : Upload of /storage/emulated/0/Android/data/com.nextcloud.client/files/nextcloud/tmp/lukebarone@cloud.lukebarone.ca/Photos//2018/08/P_20180826_190241_vHDR_Auto.jpg to /Photos//2018/08/P_20180826_190241_vHDR_Auto.jpg, chunk index 0, count 4, HTTP result status 502

2018/09/01 16:57:47
UploadFileOperation : Upload of /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg to /Photos//2018/08/P_20180826_190241_vHDR_Auto.jpg: Operation finished with HTTP status code 502 (fail)

2018/09/01 16:57:47
UploadsStorageManager : updateDatabaseUploadResult uploadResult: com.owncloud.android.lib.common.operations.RemoteOperationResult@7e0772d upload: com.owncloud.android.operations.UploadFileOperation@8b0a462

2018/09/01 16:57:47
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status:UPLOAD_FAILED and result:UNKNOWN (old:/storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg status:UPLOAD_IN_PROGRESS result:-1)

2018/09/01 16:57:47
UploadsStorageManager : Updating /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg with status=UPLOAD_FAILED

2018/09/01 16:57:47
UploadsStorageManager : updateUpload returns with: 1 for file: /storage/3465-6333/DCIM/Camera/P_20180826_190241_vHDR_Auto.jpg

2018/09/01 16:57:47
UploadsStorageManager : notifyObserversNow

2018/09/01 16:57:47
FileUploader : NotifyUploadResult with resultCode: UNHANDLED_HTTP_CODE

2018/09/01 16:57:47
UploadListAdapter : loadUploadItemsFromDb

2018/09/01 16:57:47
FileUploader : Stopping command after id 72

2018/09/01 16:58:10
OwnCloudClient #79 : Creating OwnCloudClient

2018/09/01 16:58:10
AccountUtils : Restoring cookies for lukebarone@cloud.lukebarone.ca

2018/09/01 16:58:10
OwnCloudClient #79 : REQUEST GET /index.php/204

2018/09/01 16:58:13
UploadListActivity : onPause() start

2018/09/01 16:58:13
UploadListActivity : onPause() ending

2018/09/01 16:58:13
UploadListActivity : onPause() end

2018/09/01 16:58:13
UploadListActivity : onSaveInstanceState(Bundle) starting

2018/09/01 16:58:13
UploadListActivity : onStop() ending

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => 'SECRET',
  'secret' => 'SECRET',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'SECRET.ca',
  ),
  'datadirectory' => '/mnt/data/owncloud',
  'overwrite.cli.url' => 'https://SECRET.ca',
  'dbtype' => 'mysql',
  'version' => '13.0.6.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_lukebarone',
  'dbpassword' => 'SECRET',
  'installed' => true,
  'instanceid' => 'ocoe3utu7zec',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 4,
  'updater.secret' => '$2y$10$SECRET/pZ.1QxsvaYzitQJuuwACUjc2pW4e',
);

The output of your Apache/nginx/system log in /var/log/____:

207.244.109.181 - lukebarone [01/Sep/2018:17:35:33 -0700] "GET /index.php/204 HTTP/1.1" 204 3266 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:35:46 -0700] "GET /index.php/204 HTTP/1.1" 204 3264 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:35:49 -0700] "GET /index.php/204 HTTP/1.1" 204 1363 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:35:52 -0700] "GET /index.php/204 HTTP/1.1" 204 3266 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:35:55 -0700] "GET /index.php/204 HTTP/1.1" 204 3262 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
2604:3d08:a57f:ebd0:d1ae:9538:21da:794c - - [01/Sep/2018:17:36:02 -0700] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 3097 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:07 -0700] "GET /index.php/204 HTTP/1.1" 204 3268 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:11 -0700] "GET /index.php/204 HTTP/1.1" 204 3266 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:14 -0700] "GET /index.php/204 HTTP/1.1" 204 3270 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:16 -0700] "GET /index.php/204 HTTP/1.1" 204 3262 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:18 -0700] "GET /index.php/204 HTTP/1.1" 204 3268 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:20 -0700] "GET /index.php/204 HTTP/1.1" 204 3274 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:23 -0700] "GET /index.php/204 HTTP/1.1" 204 3270 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
207.244.109.181 - lukebarone [01/Sep/2018:17:36:25 -0700] "GET /index.php/204 HTTP/1.1" 204 1361 "-" "Mozilla/5.0 (Android) ownCloud-android/3.2.3"
2604:3d08:a57f:ebd0:d1ae:9538:21da:794c - - [01/Sep/2018:17:36:32 -0700] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 3097 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"

Issue present in 3.3.0 RC1 as well

Ipv6 is disabled everywhere on the server. When I go into the app, and go to Manage Accounts, and click on my account, I get the same error (502)

Argh… Apparently, we need to restart the phones for them to realize they shouldn’t look for an IPv6 address. This is now fixed.