title: spray-client throwing "Too many open files" exception when giving more concurrent requests
body: <p>I have a spray http client which is running in a server X, which will make connections to server Y. Server Y is kind of slow(will take 3+ sec for a request)</p>
  <p>This is my http client code invocation:</p>
  <pre><code>def get() {
      val result = for {
         response &lt;- IO(Http).ask(HttpRequest(GET,Uri(getUri(msg)),headers)).mapTo[HttpResponse]
      } yield response
  
      result onComplete {
        case Success(res) =&gt; sendSuccess(res)
        case Failure(error) =&gt; sendError(res)
      }
  }
  </code></pre>
  <p>These are the configurations I have in application.conf:</p>
  <pre><code>spray.can {
      client {
              request-timeout = 30s
              response-chunk-aggregation-limit = 0
              max-connections = 50
              warn-on-illegal-headers = off
          }
          host-connector {
              max-connections = 128
              idle-timeout = 3s
            }
      }
  </code></pre>
  <p>Now I tried to abuse the server X with large number of concurrent requests(using ab with n=1000 and c=100).</p>
  <p>Till 900 requests it went fine. After that the server threw lot of exceptions and I couldn't hit the server after that.
  These are the exceptions:</p>
  <blockquote>
  <p>[info] [ERROR] [03/28/2015 17:33:13.276] [squbs-akka.actor.default-dispatcher-6] [akka://squbs/system/IO-TCP/selectors/$a/0] Accept error: could not accept new connection</p>
  <p>[info] java.io.IOException: Too many open files
  [info]     at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
  [info]     at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:241)
  [info]     at akka.io.TcpListener.acceptAllPending(TcpListener.scala:103)</p>
  </blockquote>
  <p>and on further hitting the same server, it threw the below exception:</p>
  <blockquote>
  <p>[info] [ERROR] [03/28/2015 17:53:16.735] [hcp-client-akka.actor.default-dispatcher-6] [akka://hcp-client/system/IO-TCP/selectors] null
  [info] akka.actor.ActorInitializationException: exception during creation</p>
  <p>[info]     at akka.actor.ActorInitializationException$.apply(Actor.scala:164)</p>
  <p>[info]     at akka.actor.ActorCell.create(ActorCell.scala:596)</p>
  <p>[info] Caused by: java.lang.reflect.InvocationTargetException</p>
  <p>[info]     at sun.reflect.GeneratedConstructorAccessor59.newInstance(Unknown Source)</p>
  <p>[info] Caused by: java.io.IOException: Too many open files
  [info]     at sun.nio.ch.IOUtil.makePipe(Native Method)</p>
  </blockquote>
  <p>I was previously using apache http client(which was synchronous) which was able to handle 10000+ requests with concurrency of 100.</p>
  <p>I'm not sure I'm missing something. Any help would be appreciated.</p>