title: Subscribe to Flux Websocket inbound connection with projectreactor blocking?
body: <p>In the below code, IntelliJ warns the subscribe should not be called in a blocking scope. Unfortunately subscribe seems to be the most intuitive way of associating a consumer with the inbound message stream, is there a better way?</p>
  
  <p><a href="https://i.stack.imgur.com/CXDEX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CXDEX.png" alt="Calling subscribe in non-blocking scope"></a></p>
  
  <p>Code snippet in Kotlin, based on the example Java code in the <a href="https://projectreactor.io/docs/netty/snapshot/reference/index.html#_connect" rel="nofollow noreferrer">projectreactor documentation</a>.</p>
  
  <p>I want to subscribe to the inbound messages with a consumer that is injected, or expose the inbound messages flux in a way that other consumers can access and subscribe to it and I don't want this to be blocking.</p>
  
  <pre><code>import io.netty.buffer.Unpooled
  import io.netty.util.CharsetUtil
  import reactor.core.publisher.Flux
  import reactor.netty.http.client.HttpClient
  
  fun main() {
      HttpClient.create()
          .websocket()
          .uri("wss://echo.websocket.org")
          .handle { inbound, outbound -&gt;
              inbound.receive()
                  .asString()
                  .take(1)
                  .subscribe(
                      { println(it) },
                      { println("error $it") },
                      { println("completed") }
                  )
  
              val msgBytes = "hello".toByteArray(CharsetUtil.ISO_8859_1)
              outbound.send(Flux.just(Unpooled.wrappedBuffer(msgBytes))).neverComplete()
          }
          .blockLast()
  }
  </code></pre>