Search code examples
ruby-on-railsherokuamazon-s3carrierwavesidekiq

heroku rails app mobile browser file upload timeout


I've experienced an odd behavior in my heroku rails app that I've been fighting for two days and still cannot grasp that the problem is.

I have a heroku rails app, with a feature that allows user to upload photos.

The photo upload feature works fine when uploading from desktop browser.

However, the upload feature does not work when uploading from my iphone 5 safari browser. When I tried to upload from my mobile phone browser, the client side will show application error page after about 50 seconds or so, and heroku server log would show the following lines:

2014-09-28T20:20:11.125791+00:00 heroku[router]: at=error code=H15 desc="Idle connection" method=POST path="/kitchens/1/photos" host=myapp.herokuapp.com request_id=2844a843-fff7-4c7e-aea3-fd6d393339ae fwd="24.23.199.22" dyno=web.1 connect=1ms service=55000ms status=503 bytes=0

I have conducted tests with a tiny 46KB .jpg file, on a wifi connection. The same file, on same wifi connection from desktop chrome browser upload worked fine. 46KB is a very small sized file so that leads me to believe it's not a problem with file size.

On heroku, I have two dynos, one web dyno to process normal requests, and one worker dyno to process photo in the background.

I store all my photo files on amazon S3.

I'm using the following tools and gems for photo process and upload:

Amazon S3 for storage carrierwave for processing minimagic with carrierwave carrierwave_backgrounder to hand off processing job from web server to background worker sidekiq for background worker redis-to-go for sidekiq

I'm puzzled that, why the same request, same file sent from desktop browser works while sent from mobile browser failed. My understanding is that regardless whether sent from desktop or mobile browser, the HTTP request should be the same.

Does it have to do with browser? The upload function works fine with desktop chrome and safari alike, but failed on my iphone 5 safari.

I'd really appreciate any help on this issue!

Thanks in advance.


Solution

  • It might be a DNS Problem. I tried the same process, everything works fine on chrome+iPhone6, but failed with H15 on safari+iPhone6. Both cases work well on computer (os maverick).

    Here is a similar question, with a try that works for him. H15 on Heroku SSE request

    My dns are set properly I guess and that didn't solve my problem but maybe you will be more lucky.

    EDIT: iOS8 bug http://blog.uploadcare.com/post/97884147203/you-cannot-upload-files-to-a-server-using-mobile-safari

    You can install iOS 8.0.2 to solve the problem or/and assign the IP of your server as form action to ensure response.