title: How to make a connection alive between backend and frontend?
body: <p>I have an application which has frontend written in JavaScript ( backbone) and backend written in Python.</p>
  
  <p>I am currently having a issue, the connection between frontend and backend is terminated after 2 minutes after i initialize a request. The task in backend completes after 4-5 minutes. The Frontend has to wait until it receives a notification from the backend server.</p>
  
  <p>Here is my Scenario,
  I send a ajax request to the backend. This is a very costly request that consumes RAM and CPU. This request takes almost more than 3 minutes to complete. After it is completed, the request simply sends back a JSON data with notification saying "Task completed" or "Task Failed" which needs to be displayed to the user.</p>
  
  <p>The Ajax request is very simple request,</p>
  
  <pre><code>$.ajax({
      url: server_base_url+"/json_rpc",
      method: "POST",
      headers:headers,
      data: JSON.stringify({
          id: (new Date()).getTime(),
          method: "execute",
          params: params,
      }),
      dataType: "json",
      contentType: "application/x-www-form-urlencoded; charset=UTF-8",
      success: function(data) {
          if (data.error) {
              console.log("RPC ERROR",model,method,data.error.message);
          } else {
              console.log("RPC OK",model,method,data.result);
          }
          if (cb) {
              cb(data.error,data.result);
          }
      },
      error: function() {
          console.log("RPC ERROR",model,method);
      }
  });
  </code></pre>
  
  <p>In the server side, i am using nginx to handle reverse proxy. I have already increased the timeout to 10 minutes (just for test).</p>
  
  <p>The issue i am facing is , when the costly request is made one time, the user will not receive notification even after 5 minutes, as the connection is already terminated after 2-3 minutes (by browser ?). Then the frustated user will refresh the page and hit the same button again sending a new request while the other request might be still processing or completed.</p>
  
  <p>Is there any solution to get out of this issue? Any suggestions is highly appreciated.</p>