title: Request Timeout while uploading image
body: <p>Am developing web application using <strong>golang</strong> for web server and frontend with <strong>reactJS</strong> and <strong>nodeJS</strong> to serve the frontend. I have two issue while uploading images that are big <code>(currently am testing with 2.9 mb)</code> the <strong>first</strong> one am getting is a <strong>timeout</strong> within 10 second saying request timeout at the browser side but the upload is successfully uploaded to the database. The <strong>second</strong> issue is the request is being duplicated two times and as a result the request is saved to the database two times.  I have searched on stack overflow but it doesn't seem to work. </p>
  
  <h3>First Option</h3>
  
  <p>Here is the code using ajax call i.e. fetch from isomorphic-fetch </p>
  
  <p>Following suggestion to implement a timeout wrapper at <a href="https://github.com/github/fetch/issues/175" rel="nofollow noreferrer">https://github.com/github/fetch/issues/175</a></p>
  
  <pre><code>static addEvent(events){
      let config = {
          method: 'POST',
          body: events
      };
  
      function timeout(ms, promise) {
          return new Promise(function(resolve, reject) {
              setTimeout(function() {
  
                  reject(new Error("timeout"))
              }, ms)
              promise.then(resolve, reject)
          })
      }
  
      return timeout(120000,fetch(`${SERVER_HOSTNAME}:${SERVER_PORT}/event`, config))
      .then(function(response){
          if(response.status &gt;= 400){
              return {
                  "error":"Bad Response from Server"
              };
          }else if(response.ok){
              browserHistory.push({
                  pathname: '/events'
              });
          }
      });
  }
  </code></pre>
  
  <p>The request timeout still occurs within <strong>10 seconds</strong>.</p>
  
  <h3>Second Option</h3>
  
  <p>I have tried a different node module for the ajax call i.e. <strong>axios</strong> since it has a timeout option but this also didn't fix the timeout issue.</p>
  
  <h3>Third Option</h3>
  
  <p>I tried to set read timeout and write timeout on the server side similiar to <a href="https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/" rel="nofollow noreferrer">https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/</a></p>
  
  <pre><code>server := &amp;http.Server{
      Addr:         ":9292",
      Handler:      router,
      ReadTimeout:  180 * time.Second,
      WriteTimeout: 180 * time.Second,
  }
  </code></pre>
  
  <p>Again am getting request timeout at browser side within <strong>10 seconds</strong>. </p>
  
  <p>what shall I do to fix or point me if i made a mistake ?</p>