0

I'm trying to download a dropbox link to a file output.txt. Something like this:

URL link = new URL("https://dl.dropboxusercontent.com/1/view/XXX/file.txt");
ReadableByteChannel rbc = Channels.newChannel(link.openStream());
FileOutputStream fos = new FileOutputStream("output.txt");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);

When I'm running my app in development (i.e. activator run) this works fine. When the app is staged and deployed in production, I get a connection timeout at the link.openStream() step:

play.api.UnexpectedException: Unexpected exception[ConnectException: Connection timed out]

I'm able to save any http files or websites to file in production. It just seems to time out on any https file. Any thoughts on how I could begin to tackle this?

Does this have anything to do with play or is it a configuration issue with my apache server?

Thanks

Omar Wagih
  • 8,504
  • 7
  • 59
  • 75

1 Answers1

0

You could have the problem with configuration or with access from that server to that URL. That is an easy part.

You also could have the problem with SSL certificate. So you will need to download it and add it locally or ask the server owners (that one server - "https://dl.drop ... ") to fix the certificate (it could be a problem on their side as well).

To verify that you have the problem with certificates - you can use the code described in this question Java and HTTPS url connection without downloading certificate DO NOT USE THIS CODE IN PRODUCTION - because you security will be 0, this code force you to trust to any certificate, so "https" naturally becomes "http" for you.

The reason of a second problem (I got if few times) was that production environment had more strict security settings, and the server where I read https resources have some problem with certification, like expiration, or incorrectly re-certified.

Community
  • 1
  • 1
Andriy Kuba
  • 8,093
  • 2
  • 29
  • 46