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

configuration for http2 #649

Closed
3 tasks done
tcurdt opened this issue Sep 7, 2016 · 6 comments
Closed
3 tasks done

configuration for http2 #649

tcurdt opened this issue Sep 7, 2016 · 6 comments
Assignees
Labels

Comments

@tcurdt
Copy link

tcurdt commented Sep 7, 2016

Description

I was following the example trying to start a http2 server (and also combine it with graceful).

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

If the TLS files are missing it should fail - but doesn't.
I should be able to define whether I want HTTP2 or not.

Actual behaviour

No HTTPS

$ curl https://localhost:8000/
curl: (35) Unknown SSL protocol error in connection to localhost:-9847

Just plain old HTTP 1.1

$ curl -I -X GET http://localhost:8000/
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Wed, 07 Sep 2016 19:31:16 GMT
Content-Length: 6

I now even have the TLS files in place - but no clue if they are found or not. And it behaves the same way.

Steps to reproduce

Run the code below and use the curl lines from above

Working code to debug

package main

import (
  "net/http"
  "time"

  "github.com/labstack/echo"
  "github.com/labstack/echo/engine"
  "github.com/labstack/echo/engine/standard"
  "github.com/tylerb/graceful"
)

func Index(c echo.Context) error {
  return c.String(http.StatusOK, "Index\n")
}

func main() {

  mux := echo.New()
  mux.GET("/", Index)

  std := standard.WithConfig(engine.Config{
    Address:     ":8000",
    TLSCertFile: "../cert.pem",
    TLSKeyFile:  "../key.pem",
  })
  std.SetHandler(mux)
  graceful.ListenAndServe(std.Server, 5*time.Second)
}

Version/commit

"revision": "65b60a4ed28e2fc6e0c25aebecbd1ba566d77a60",
@vishr
Copy link
Member

vishr commented Sep 7, 2016

If the TLS files are missing it should fail - but doesn't.

Why it should fail? You can define engine.Config without TLSCertFile or TLSKeyFile, in that case it will run server in non-tls mode. It should fail for invalid or not-found files and it does.

I should be able to define whether I want HTTP2 or not.

We can work on this, please provide input on providing this flag or option in the config.

PS: The recipe is little off, I will update it soon.

@vishr vishr self-assigned this Sep 7, 2016
@vishr vishr added the question label Sep 7, 2016
@tcurdt
Copy link
Author

tcurdt commented Sep 7, 2016

It should fail for invalid or not-found files and it does.

I think we are in agreement then - but it does not fail for me.

@tcurdt
Copy link
Author

tcurdt commented Sep 7, 2016

...unless that's maybe because of graceful?

@vishr
Copy link
Member

vishr commented Sep 7, 2016

@tcurdt can you try without graceful?

@tcurdt
Copy link
Author

tcurdt commented Sep 7, 2016

Ha!

panic: echo: open ../cert.pem: no such file or directory

with the files it then works (without graceful):

$ curl -k -X GET -I https://localhost:8000/
HTTP/2 200 
content-type: text/plain; charset=utf-8
content-length: 6
date: Wed, 07 Sep 2016 21:40:36 GMT

I guess then the question is how handle this in a graceful scenario.

vishr added a commit that referenced this issue Sep 11, 2016
Signed-off-by: Vishal Rana <vr@labstack.com>
@vishr
Copy link
Member

vishr commented Sep 11, 2016

@tcurdt We have DisableHTTP2 flag in the config now. To use HTTP2 with graceful you need to do something like below:

e := echo.New()
s := standard.WithConfig(engine.Config{
    Address: ":1323",
})
s.SetHandler(e)
graceful.ListenAndServeTLS(s.Server, "cert.pem", "key.pem", 5*time.Second)

@vishr vishr closed this as completed in 322b375 Sep 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants