2 Replies Latest reply on Sep 4, 2014 12:03 AM by Alexey Mironov

    504 and 502 errors

    Alexey Mironov


      Our clients have an Rhomobile and Rho Connect App's.

      At last time offen we seen an 504 error on mobile device log. I read about it and we change time out Nginx variables :


          proxy_connect_timeout 30;

          proxy_send_timeout    30;

          proxy_read_timeout 30;


          proxy_connect_timeout 180;

          proxy_send_timeout    180;

          proxy_read_timeout 180;

      After then we have offen to get 502 error....

      We have 20 mobile devices (sync freq.1-2 sync by 30 min).

      Sync server - HP 4 CPU 4GB RAM (RedHat 6.5)

      Sync protocol is HTTPS with SSL one side server side encrypting...


      Coud some body recomend me what can I do?

        • Re: 504 and 502 errors
          Jon Tara

          Many mobile networks will not permit a connection to go idle for that long.


          30 seconds I think is a safe number - I believe this is what Verizon uses, and I think they have the shortest timeout.


          I would investigate why your server is taking so long to respond. It seems unreasonable.

            • Re: 504 and 502 errors
              Alexey Mironov

              Thank Jon,

              but this error dose not network acess (delay) reason. It hapend near Nging and Thin -

              Nging Log sad (for example):


              2014/09/03 11:45:49 [error] 19416#0: *3359 upstream prematurely closed connection while reading response header from upstream, client:, server: inkscodes.voz.ru, request: "GET /app/v1/Users?p_size=2000&version=3&token=178973080779412&query[device_id]=b44d9d14f067e7ff1a9b HTTP/1.1", upstream: "http://unix:/tmp/thin.0.sock:/app/v1/Users?p_size=2000&version=3&token=178973080779412&query[device_id]=b44d9d14f067e7ff1a9b", host: "inkscodes.voz.ru:8443"


              Thin do some connection to ORACLE DB. Some times this connect have dellay but it is not critical.

              Thin Log dose not have any errors. It like Thin miss my ruby handler's (as query data).


              This effect not stable and happend some times...


              I want to add additional upstream for Thin -


              server unix:/tmp/thin.2.sock;

              server unix:/tmp/thin.3.sock;


              and add wait delay:


              environment: production

              timeout: 180

              log: /var/log/thin/thin.log

              pid: /var/run/thin/thin.pid

              max_conns: 1024

              max_persistent_conns: 512

              require: []

              wait: 180

              socket: /tmp/thin.sock

              servers: 4

              daemonize: true

              what did you think about it?