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

No way to access close frame in WebSocketBuilder #6806

Open
armanbilge opened this issue Nov 13, 2022 · 1 comment
Open

No way to access close frame in WebSocketBuilder #6806

armanbilge opened this issue Nov 13, 2022 · 1 comment

Comments

@armanbilge
Copy link
Member

def withOnClose(onClose: F[Unit]): WebSocketBuilder2[F] =
copy(onClose = onClose)

Also, at least ember server is not including the close frame in the Stream of incoming frames /shrug

@monzonj
Copy link

monzonj commented Nov 29, 2022

Hello.

I confirm this, but only applies to http4s-ember-server, it works fine with Blaze

For example, a simple websocket that logs all income messages. I expect "close" control frames to also be printed out

EmberServerBuilder
          .default[IO]
          .withHost("0.0.0.0")
          .withPort(8080)
          .withHttpWebSocketApp { builder =>
            HttpRoutes
              .of[IO] { case GET -> Root / "endpoint" =>
                val inOut: Pipe[IO, WebSocketFrame, WebSocketFrame] =
                  _.map { m =>
                    println(m.toString)
                    m
                  }
                builder.build(inOut)
              }
              .orNotFound
          }
          .build

You can run this server and test with https://websocketking.com/. Open a WS there and then close it... no printout.

All right, let's do the same with the Blazer server

BlazeServerBuilder[IO]
          .bindHttp("0.0.0.0", 8080)
          .withHttpWebSocketApp { builder =>
            HttpRoutes
              .of[IO] { case GET -> Root / "endpoint" =>
                val inOut: Pipe[IO, WebSocketFrame, WebSocketFrame] =
                  _.map { m =>
                    println(m.toString)
                    m
                  }
                builder.build(inOut)
              }
              .orNotFound
          }
          .serve

Same test and yes, the close frame is received and printed out

Seems a bug in the new Ember server.

acteek pushed a commit to acteek/http4s that referenced this issue Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants