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

WebSocketConfig.withForwardCloseFrames does not forward Close frames #2375

Closed
webberaj81 opened this issue Aug 8, 2023 · 9 comments
Closed
Labels
💎 Bounty bug Something isn't working 💰 Rewarded

Comments

@webberaj81
Copy link
Contributor

Describe the bug
When creating a WebSocketConfig with withForwardCloseFrames(true), Close frames are not forwarded.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a SocketApp with a Handler that maps Read(WebSocketFrame.Close) to some observable behavior, e.g., Console.printLine
  2. Provide this SocketApp a ZClient configured with a WebSocketConfig using withForwardCloseFrames(true)
  3. Connect this client to a Server serving a SocketApp.
  4. Have this Server send a Close frame to the client
  5. Notice that the client does not invoke the behavior mapped to the Read(WebSocketFrame.Close) event

Expected behaviour
Methods have functionality consistent with their naming

Additional context
WebSocketConfig.withForwardCloseFrames(false) does forward the Close frames to the client, which is contradictory to it's name, and to the behavior of its sibling method, WebSocketConfig.withForwardPongFrames, which requires true to be made visible to the Client/Server

To put this another (more readable) way, this is what the WebSocketClient from the example code would need to be to see Close frames and Pong frames, both of which are not available by default:

  val run: ZIO[Scope, Throwable, Any] =
    ZIO.scoped {
      app.provideSome[Scope](
        ZLayer.succeed(
          Client.Config.default.withWebSocketConfig(
            WebSocketConfig
            .default
            .withForwardCloseFrames(false) // <- FALSE To see them
            .withForwardPongFrames(true), // <- TRUE To see them
          ),
        ) ++ ZLayer.succeed(NettyConfig.default)
          ++ DnsResolver.default >>> Client.live
        )
    }
}
@webberaj81 webberaj81 added the bug Something isn't working label Aug 8, 2023
@jdegoes
Copy link
Member

jdegoes commented Aug 17, 2023

/bounty $75

@algora-pbc
Copy link

algora-pbc bot commented Aug 17, 2023

💎 $75 bounty created by jdegoes
🙋 If you start working on this, comment /attempt #2375 to notify everyone
👉 To claim this bounty, submit a pull request that includes the text /claim #2375 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to zio/zio-http!

Attempt Started (GMT+0) Solution
🟡 @webberaj81 Aug 18, 2023, 4:36:32 PM #2395
🟡 @an0nym3sh Sep 26, 2023, 10:59:20 AM WIP

@webberaj81
Copy link
Contributor Author

webberaj81 commented Aug 18, 2023

/attempt #2375

Options

@Syed-Taha381
Copy link

val run: ZIO[Scope, Throwable, Any] =
ZIO.scoped {
app.provideSome[Scope](
ZLayer.succeed(
Client.Config.default.withWebSocketConfig(
WebSocketConfig
.default
.withForwardCloseFrames(false) // Set to true to forward Close frames initiated by server
.withForwardPongFrames(true),
),
) ++ ZLayer.succeed(NettyConfig.default)
++ DnsResolver.default >>> Client.live
)
}
}

Try that

@algora-pbc
Copy link

algora-pbc bot commented Aug 21, 2023

💡 @webberaj81 submitted a pull request that claims the bounty. You can visit your org dashboard to reward.

webberaj81 added a commit to webberaj81/zio-http that referenced this issue Aug 21, 2023
…rward Close frames

fix typos, clarify descriptor

add WebSocketConfig unit test for forwardCloseFrames
@an0nym3sh
Copy link

an0nym3sh commented Sep 26, 2023

/attempt #2375

Options

@algora-pbc
Copy link

algora-pbc bot commented Sep 26, 2023

Note: The user @webberaj81 is already attempting to complete issue #2375 and claim the bounty. If you attempt to complete the same issue, there is a chance that @webberaj81 will complete the issue first, and be awarded the bounty. We recommend discussing with @webberaj81 and potentially collaborating on the same solution versus creating an alternate solution.

@algora-pbc
Copy link

algora-pbc bot commented Oct 3, 2023

@an0nym3sh: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

adamgfraser pushed a commit that referenced this issue Oct 8, 2023
… frames #2375  (#2395)

* fix bug #2375 - WebSocketConfig.withForwardCloseFrames does not forward Close frames

fix typos, clarify descriptor

add WebSocketConfig unit test for forwardCloseFrames

* * scalafmtAll

* * scalafmtAll

* * typo fix

* squash!  * typo fix

 * scalafmtAll

* squash! squash!  * typo fix

 * remove unused layer

* squash! squash! squash!  * typo fix

 * run sFix
@algora-pbc
Copy link

algora-pbc bot commented Oct 8, 2023

🎉🎈 @webberaj81 has been awarded $75! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty bug Something isn't working 💰 Rewarded
Projects
None yet
Development

No branches or pull requests

5 participants