io.tus.java.client.ProtocolException while trying to upload the file

Issue:
I’m using the tus-java-client JAR to transfer files from one system to another via IP and port, with NGINX as a reverse proxy. While uploading, I get the following error:

io.tus.java.client.ProtocolException: unexpected status code (502) while creating upload
at io.tus.java.client.TusClient.createUpload(TusClient.java:211)
at io.tus.java.client.TusClient.resumeOrCreateUpload(TusClient.java:334)
at com.xxx.fileuploader.FilePusherTrace.uploadChunkWithResume(FilePusherTrace.java:835)
at com.xxx.fileuploader.FilePusherTrace.lambda$uploadAllChunksConcurrently$11(FilePusherTrace.java:723)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1583)

What could be causing this 502 Bad Gateway error during upload creation? Where should I start debugging? Do i need to enable any permission in the server side system??

A 502 response code means that the Nginx proxy wasn’t able to reach the origin server. There are many reasons why this could happen, but frequent causes are that the address of the origin server is not correct or that Nginx timed out while waiting for a response from the origin. The Nginx logs might help you debug this. I can also recommend reading Configuration | tusd documentation, which provides details on proxy configuration for tus servers. Although the documentation is for tusd specifically, similar advice is helpful for other server as well.

That being said, there is nothing that can be done on the client-side about a 502 response.

1 Like