# Stuck on #EJ5 Received: "" (no content received) but code works locally

**URL:** <https://forum.codecrafters.io/t/stuck-on-ej5-received-no-content-received-but-code-works-locally/15976>\
**Category:** Challenges\
**Tags:** challenge:http-server\
**Created:** [March 11, 2026, 2:11pm UTC](https://forum.codecrafters.io/t/stuck-on-ej5-received-no-content-received-but-code-works-locally/15976 "2026-03-11T14:11:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flaviapodariu](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/flaviapodariu/32/15938_2.png) [@flaviapodariu](https://forum.codecrafters.io/u/flaviapodariu)\
**Post date:** [March 11, 2026, 2:11pm UTC](https://forum.codecrafters.io/t/stuck-on-ej5-received-no-content-received-but-code-works-locally/15976/1 "2026-03-11T14:11:32Z")

</div>

I’m using Scala and I’m stuck on Stage #EJ5. I keep getting this error: Received: “” (no content received), but locally I cannot reproduce this issue. At this point I’m not sure if this is an issue on my side or if it’s a bug

I’ve tested my code with oha:  
`oha -n 3 -c 3 ``http://localhost:4221`

Here are my logs:

```auto
accepted new connection from null:49204
accepted new connection from null:49203
accepted new connection from null:49205
Response HTTP/1.1 200 OK\r\n\r\n was sent to client on port 49203
Response HTTP/1.1 200 OK\r\n\r\n was sent to client on port 49205
Response HTTP/1.1 200 OK\r\n\r\n was sent to client on port 49204
OK
OK
OK

```

And here’s a snippet of my code:

```python
@main def main(): Unit = {
  val CRLF = "\r\n"
  val HTTP_VERSION = "HTTP/1.1"
  val serverSocket = new ServerSocket(4221)
  serverSocket.setReuseAddress(true)

  while (true) {
    val clientSocket = serverSocket.accept()
    println(
      s"accepted new connection from ${clientSocket.getChannel()}:${clientSocket.getPort()}"
    )

    Future {
      handleClient(HTTP_VERSION, clientSocket)
    }.onComplete {
      case Success(_) => println("OK")
      case Failure(e) => println(s"Error handling client: ${e.getMessage}")
    }
  }

}

def handleClient(httpVersion: String, clientSocket: Socket): Unit = {
  try {
    val inputStream = clientSocket.getInputStream()
    val reader = new BufferedReader(new InputStreamReader(inputStream))

    val rawRequest = Iterator
      .continually(reader.readLine())
      .takeWhile(it => it != null && it.nonEmpty)
      .toList

    val request = HttpRequest.parse(rawRequest)

    val outputStream = clientSocket.getOutputStream()

    val response = request.line.path match {
      case "/" => HttpResponse(StatusCode.OK)
      case echo if echo.startsWith("/echo/") =>
        HttpResponse(StatusCode.OK, body = echo.stripPrefix("/echo/"))
      case userAgent if userAgent.startsWith("/user-agent") =>
        HttpResponse(
          StatusCode.OK,
          body = request.headers.getOrElse(USER_AGENT, "")
        )
      case _ => HttpResponse(StatusCode.NOT_FOUND)
    }
    val responseBytes = response.toBytes(httpVersion)
    outputStream.write(responseBytes)
    outputStream.flush()
    val a = String(responseBytes).replace("\r\n", "\\r\\n")
    println(s"Response $a was sent to client on port ${clientSocket.getPort}")
  } catch {
    case e: IOException =>
      println(s"IOException: ${e.getMessage}")
  } finally {
      clientSocket.close()
  }
}

```

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [March 11, 2026, 5:16pm UTC](https://forum.codecrafters.io/t/stuck-on-ej5-received-no-content-received-but-code-works-locally/15976/3 "2026-03-11T17:16:19Z")

</div>

Hey @flaviapodariu, `ExecutionContext.Implicits.global` implicitly uses a thread pool whose size is based on the number of available processors.

Since our testers run on **single-CPU machines** , that effectively means only one worker thread is available, so your code won’t be able to handle connections concurrently by default.

You can create your own execution context with a larger thread pool instead of using the global one. For example:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/3/c/3c20188b63a50423ba1fe29c64388bd8f845f94f.png)

Let me know if you’d like any further clarification!

---

<div class="post-metadata">

**Author:** ![flaviapodariu](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/flaviapodariu/32/15938_2.png) [@flaviapodariu](https://forum.codecrafters.io/u/flaviapodariu)\
**Post date:** [March 12, 2026, 9:20am UTC](https://forum.codecrafters.io/t/stuck-on-ej5-received-no-content-received-but-code-works-locally/15976/5 "2026-03-12T09:20:01Z")

</div>

Ooh it makes a lot of sense, thanks a lot!  
Also, for anyone interested, a good way to reproduce the issue locally would be to add this JVM flag (under VM options if using IntelliJ): `-XX:ActiveProcessorCount=1` .

Then connect to the server from a terminal and do a curl from another terminal. This will hang until the first connection will be closed. This is also way easier than using oha or other similar tools 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [March 17, 2026, 9:21am UTC](https://forum.codecrafters.io/t/stuck-on-ej5-received-no-content-received-but-code-works-locally/15976/6 "2026-03-17T09:21:01Z")

</div>

Closed on March 17, 2026, 9:21am UTC

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
