support allowHalfOpen=false and add tests