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

Ember Web Socket Client #7261

Open
wants to merge 96 commits into
base: series/0.23
Choose a base branch
from

Conversation

danghieutrung
Copy link
Contributor

@danghieutrung danghieutrung commented Sep 1, 2023

Complete PR of ember-wsclient implementation.

Snapshot

Published as 0.23.23-101-eb5dd80-SNAPSHOT. Supports JVM, Node.js, Native — please give it a try!

libraryDependencies += "org.http4s" %% "http4s-ember-client" % "0.23.23-101-eb5dd80-SNAPSHOT"
resolvers += "s01-oss-sonatype-org-snapshots" at "https://s01.oss.sonatype.org/content/repositories/snapshots"

https://github.com/http4s/http4s/actions/runs/6000578477/attempts/1#summary-16274325476

Demo

//> using repository https://s01.oss.sonatype.org/content/repositories/snapshots/
//> using dep org.http4s::http4s-ember-client::0.23.23-101-eb5dd80-SNAPSHOT

import cats.effect.*
import org.http4s.ember.client.EmberClientBuilder
import org.http4s.client.websocket.*
import org.http4s.syntax.all.*

object App extends IOApp.Simple:
  def run = EmberClientBuilder .default[IO].buildWebSocket.use { (client, wsClient) =>
    wsClient
      .connectHighLevel(WSRequest(uri"wss://ws.postman-echo.com/raw"))
      .use { conn =>
        conn.send(WSFrame.Text("hello from ember websockets")) *>
          conn.receive.flatMap(IO.println(_))
      }
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! We can now move this suite from jvm-only to shared :)

@armanbilge armanbilge linked an issue Oct 12, 2023 that may be closed by this pull request
@armanbilge
Copy link
Member

If the Ember client is created withHttp2 enabled, then it causes the java.lang.RuntimeException: Not an Ember client error. This is because the connection upgrades to HTTP/2 but we don't support upgrading to WebSockets over HTTP/2.

To fix this we need some way to force Ember to always use HTTP/1 when negotiating a WebSocket upgrade 🤔

@armanbilge armanbilge mentioned this pull request Nov 16, 2023
@armanbilge
Copy link
Member

Update: I think we're almost ready to merge this, but there is still at least one bug that needs to be investigated. The kubernetes-client is attempting to adopt the Ember WS client but it's not 100% working yet.

Help would be very appreciated!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ember Client WebSocket support
2 participants