Skip to content

Troubleshooting Procedure

Alex Gotev edited this page Oct 17, 2020 · 22 revisions

Let's face it, doing network programming is not easy as there are many things that can go wrong, but if upload doesn't work out of the box:

  • make sure you have followed the steps described in this wiki, in which you can find how to setup everything and make it work
  • search in the issues. Your question may have already been answered.
  • Is the server URL correct?
  • Is the server URL reachable from your device? Check if there are firewalls or other kind of restrictions between your device and the server.
  • Are you sure that the server side is working properly? For example, if you use PHP in your server side, and you get an EPIPE exception, check if the content size you are trying to upload exceeds the values of upload_max_filesize or post_max_size set in your php.ini
  • Have you properly set up the request with all the headers, parameters and files that the server expects?
  • Have you tried to make an upload using the demo app and demo server? I use the node.js version which provides good feedback and supports both HTTP Multipart and binary uploads.
  • Can you successfully make an upload to your server URL with a browser or some other tool? If no, check your server. If yes, enable library debug logging and check the code you used to create the request. A dump with wireshark is useful in those cases, to discover what is the difference between the working request and the wrong one.
  • If you are using HTTPS, be sure to have valid and trusted certificates on your server. You can easily check by visiting your server address from Google Chrome or Mozilla Firefox. If a security message pops up, then something is wrong with your certificates. Fix that. If you just want to ignore that exception while you are testing in your own environment, go in the advanced topics of the wiki and see how to enable self-signed certificates.

Track network requests and responses in Chrome

Android Upload Service Demo app has Facebook Stetho integrated. This means that to track what happens on the network, you have to do the following:

  • deploy the upload service demo app to a virtual device or your physical device connected to your LAN,
  • launch Google Chrome, navigate to chrome://inspect
  • click on inspect, then switch to the Network tab

Now you can see all the requests and responses directly with Chrome Developer Tools! If you integrate Facebook Stetho in your app, you can do the same! Pretty cool, huh?

Dump network traffic

If something is not working as expected when you perform an upload and you can't figure out where the problem really is, dump the network traffic and analyze requests and responses with Wireshark. An useful free tool to dump the network traffic directly on your device is tPacketCapture. It creates a .pcap file in /sdcard/Android/data/jp.co.taosoftware.android.packetcapture/files/ ready to be transferred to your computer (you can use Dukto for that), which you can open with Wireshark. Top 10 reasons to learn Wireshark.

Android 6.0 Permissions

Permissions needed by the library are listed in the manifest. As stated here, only android.permission.WRITE_EXTERNAL_STORAGE is considered dangerous, so you have to make sure that your apps has that permission granted. It's needed to be able to select files for upload and delete successfully uploaded files.

SSLHandshakeException on Android 4 (Android API < 21)

If your server uses modern certificates which support TLS 1.2, you may have problems on older Android devices. This is due to the fact that TLS 1.2 is not enabled by default on those devices even if it's implemented, so you may have SSLHandshakeException. Check this issue to solve this problem. Bear in mind the solution may not work on all devices, as hardwares which runs Android prior to 5.0 may not have the capabilities required by TLS 1.2.

Clone this wiki locally