soheilhy / cmux

Connection multiplexer for GoLang: serve different services on the same port!
Apache License 2.0
2.53k stars 197 forks source link

Server unexpectedly doesn't receive traffic from cmux.Any() #73

Closed majelbstoat closed 4 years ago

majelbstoat commented 4 years ago

I have a server that receives traffic from a standard tcp listener, but doesn't receive traffic from a cmux.Any() connection derived from the same listener. I have a small, reproducible case:

This works (i.e. can receive traffic):

  listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
  if err != nil {
    logger.Fatal("Could not listen on port.")
  }

  go grpcServer.Start(listener) // Works - connections are received and processed.

This doesn't work (i.e. connection hangs when making a request):

  listener, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
  if err != nil {
    logger.Fatal("Could not listen on port.")
  }
  m := cmux.New(listener)
  grpcListener := m.Match(cmux.Any())

  go grpcServer.Start(grpcListener) // Doesn't work - connections hang.
majelbstoat commented 4 years ago

Ugh. missing m.Serve(). PEBKAC.