Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server closes prematurely connection when "Connection: close" header was present in request #707

Closed
almendar opened this issue Jan 3, 2017 · 2 comments
Milestone

Comments

@almendar
Copy link

almendar commented Jan 3, 2017

Sample sever:

package pl.tk.akkahttp

import akka.actor._
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.server.Directives._
import akka.stream._

import scala.util.Random

object Main extends App {
  implicit val system = ActorSystem("system")
  implicit val materializer = ActorMaterializer()


  val route = (path("test") & post) {
    entity(as[String]) { s⇒
      complete {
        Random.nextString(1 * 1024 * 1024)
      }
    }
  }


  Http()
    .bindAndHandle(Route.seal(route), "localhost", 8080)
}

curl script:

API=http://localhost:8080/test
curl \
    -s \
    -v \
    -H 'Host:localhost' \
    -H 'Content-Type:application/json; charset=UTF-8' \
    -H 'Connection: close' \
    -X POST \
    $API \
    --data-binary '{
}'

output:

➜  akka-http-connection-close ./reproduce.sh 1>/dev/null
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /test HTTP/1.1
> Host:localhost
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type:application/json; charset=UTF-8
> Connection: close
> Content-Length: 3
>
} [3 bytes data]
* upload completely sent off: 3 out of 3 bytes
< HTTP/1.1 200 OK
< Server: akka-http/10.0.1
< Date: Tue, 03 Jan 2017 11:07:18 GMT
< Connection: close
< Content-Type: text/plain; charset=UTF-8
< Content-Length: 3104407
<
{ [16217 bytes data]
* Recv failure: Connection reset by peer
* Curl_http_done: called premature == 1
* Closing connection 0

tested on:
"com.typesafe.akka" %% "akka-http" % "10.0.1"
"com.typesafe.akka" %% "akka-http-experimental" % "2.4.11"
scalaVersion in ThisBuild := "2.11.8"

@jrudolph
Copy link
Member

jrudolph commented Jan 3, 2017

Thanks for the report, @almendar. Probably a duplicate of #459. Can you check if that ticket matches?

@jrudolph
Copy link
Member

jrudolph commented Jan 4, 2017

Closing as duplicate for now. Please reopen if the problem prevails after that has been fixed. I created a fix yesterday. If you want you could try if the fix in PR #708 fixes it for you. Thanks!

@jrudolph jrudolph closed this as completed Jan 4, 2017
@jrudolph jrudolph added this to the duplicate milestone Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants