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.NewServer use http2 some bug #2030

Open
doraHope opened this issue Apr 2, 2023 · 0 comments
Open

server.NewServer use http2 some bug #2030

doraHope opened this issue Apr 2, 2023 · 0 comments

Comments

@doraHope
Copy link

doraHope commented Apr 2, 2023

Describe the bug
i use http2 protocol start a server. but i meet some wrong.
#1 response miss content-length
#2 server conn will close before reply response when get a data frame with end flag.
#3 some bad code.
example:
func: server.rpcServer.ServeConn:
/**
go func(id string, psock *socket.Socket) {
wg.Add(1)
// add to the waitgroup
......
}
*/

To Reproduce
Server Start Code:
/**
func main() {
cert, err := tls.LoadX509KeyPair(<pub>, <key>)
if err != nil {
log.Printf(key pair failed, error %v, err)
return
}
srv := server.NewServer(server.Name(testABC), server.Transport(transport.NewTransport(transport.TLSConfig(&tls.Config{
InsecureSkipVerify: true,
Certificates: []tls.Certificate{cert},
NextProtos: []string{h2, http/1.1},
}), transport.Secure(true))))
srv.Init(server.Wait(nil))
err = srv.Handle(srv.NewHandler(&HelloServer{}))
if err != nil {
log.Printf("new handler failed, error %v", err)
return
}
err = srv.Start()
if err != nil {
log.Printf("go-micro start failed")
}

ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)

select {
// wait on kill signal
case <-ch:
// wait on context cancel
case <-srv.Options().Context.Done():

}

srv.Stop()

}
*/

request server example:

curl request:
curl --http2 --keepalive-time 60 --cacert -iv -H 'Content-Type: application/json'
-H 'Micro-Service: HelloServer'
-H 'Micro-Method: Call'
-H 'Micro-Endpoint: HelloServer.Call'
--data-raw '{}'
-H 'Connection: keep-alive'
https://addr/

curl response:

  • Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
    < HTTP/2 200
    HTTP/2 200
    < content-type: application/json
    content-type: application/json
    < date: Sun, 02 Apr 2023 08:47:55 GMT
    date: Sun, 02 Apr 2023 08:47:55 GMT

<
{"A":"hello world"}

  • Connection #0 to host dc.com left intact

Expected behavior
#1 when receive frame data with end flag, close conn after reply response.
#2 bad code, may cause response can not reply.
#3 http2 response header should have 'Content-Length'.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Mac
  • Browser curl/7.84.0
  • Version 13.0

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

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

1 participant