title: Spray.IO Stop http server with Http.Unbind
body: <p>I have an app built on spray 1.3.3 and I'm trying to stop http server by sending message.
  Official documentation says:</p>
  
  <blockquote>
    <p>Stopping. To explicitly stop the server, send an Http.Unbind command to
    the HttpListener instance (the ActorRef for this instance is available
    as the sender of the Http.Bound confirmation event from when the
    server was started).</p>
  </blockquote>
  
  <p>Here is how i the start server:</p>
  
  <pre><code>(IO(Http) ? Http.Bind(httpListener, interface = iface, port = port)).map {
  case m: Http.Bound =&gt; println(s"Success $iface:$port")
  case fail : Http.CommandFailed =&gt; println(s"Bad try :(")
  }
  </code></pre>
  
  <p>I tried to send message Http.Unbind to httpListener but with no success. Seems to be it's not that actor</p>
  
  <p>May be i need to extract somehow sender ref of Http.Bound message? But how?</p>
  
  <p>Here is my httpListener's head:</p>
  
  <pre><code>class MyHttpListener extends HttpServiceActor {
  
    import context.dispatcher
  
    def receive = runRoute(
  
      path("shutdown") {
  
        get {
  
          actors.httpListener ! Http.Unbind
          complete("Stopping server")
  
        }
  
      }
  </code></pre>
  
  <p>Anyway, i just want to send http request to /shutdown and have my application be down</p>