title: Getting java.io.IOException: Broken pipe exception when navigating in a video that is being streamed as a multi part file stream
body: <p>I am playing around with a simple video streaming spring boot application using the <code>MultipartFileSender</code> class in <a href="https://github.com/davinkevin/Podcast-Server/blob/d927d9b8cb9ea1268af74316cd20b7192ca92da7/src/main/java/lan/dk/podcastserver/utils/multipart/MultipartFileSender.java" rel="nofollow noreferrer">this</a> github repository. Since it is a very big file I didn't want to include it here but if needed I can include it.</p>
  
  <p>I have my controller as follows:</p>
  
  <pre><code>package org.murat.test.controllers;
  
  import org.murat.test.Utils.MultipartFileSender;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.io.File;
  
  @RestController
  @RequestMapping("/")
  public class VideoController {
      protected final Logger logger = LoggerFactory.getLogger(this.getClass());
  
      @RequestMapping(value = "video", method = RequestMethod.GET)
      public void getVideo(HttpServletRequest request, HttpServletResponse response){
          File file = new File("/test-videos/BigBuckBunny.mp4");
          try {
              logger.debug("Streaming file '" + file.getName() + "'...");
              MultipartFileSender.fromFile(file)
                      .with(request)
                      .with(response)
                      .serveResource();
          } catch (Exception e) {
              String errorMessage = e.getLocalizedMessage();
              logger.error(errorMessage, e);
          }
      }
  }
  </code></pre>
  
  <p>Everything runs perfectly as I go to  the URL <a href="http://hostname:8080/video" rel="nofollow noreferrer">http://hostname:8080/video</a> and I can play, pause, rewind and navigate in the video.</p>
  
  <p>My only concern at this point is, every time I navigate around the video (even when I start it) I get the <code>org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe</code> exception.</p>
  
  <p>I did a bit of research and found out that this happens if the user closes the website or their connection when the server is trying to serve something to the user. So in my case this happens because when I drag to another frame:</p>
  
  <ol>
  <li>Video pauses. </li>
  <li>Goes to the desired frame. </li>
  <li>Video starts running from that
  frame.</li>
  </ol>
  
  <p>I assume at this point the original connection is lost and another one is created.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Can I make the switch between the connections gracefully without getting this error? </li>
  <li>If not, can I safely ignore this error (perhaps force it to
  display it as warning/debug when I catch this particular exception)?</li>
  </ol>