# How to construct bridge between client-side websocket and server-side websocket

**URL:** <https://discuss.akka.io/t/how-to-construct-bridge-between-client-side-websocket-and-server-side-websocket/5074>\
**Category:** Akka Streams & Alpakka\
**Tags:** akka-http, websockets, streams\
**Created:** [September 16, 2019, 9:57pm UTC](https://discuss.akka.io/t/how-to-construct-bridge-between-client-side-websocket-and-server-side-websocket/5074 "2019-09-16T21:57:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkulikov](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/vkulikov/32/1355_2.png) [@vkulikov](https://discuss.akka.io/u/vkulikov)\
**Post date:** [September 16, 2019, 9:57pm UTC](https://discuss.akka.io/t/how-to-construct-bridge-between-client-side-websocket-and-server-side-websocket/5074/1 "2019-09-16T21:57:55Z")

</div>

Hello!  
Let’s say we want to connect to external WebSocket API using

```auto
val webSocketFlow: Flow[Message, Message, Future[WebSocketUpgradeResponse]] =
      Http().webSocketClientFlow(WebSocketRequest("wss://..."))

val incoming: Sink[Message, Future[Done]] = Sink.foreach[Message] { ... }

val outgoing = Source.maybe[Message]

val (upgradeResponse: Future[WebSocketUpgradeResponse], closed: Future[Done]) =
      outgoing
        .viaMat(webSocketFlow)(Keep.right)
        .toMat(incoming)(Keep.both) 
        .run()

```

Does it possible to stream this data to internal clients (to microservices which providing real-time analytics) using own WS endpoint?  
To make this possible, I need to “connect” `incoming` sink from code above to `msFlow` below, but I have no idea, how to define `msFlow`

```auto
val websocketRoute =
          path("ms") {
            handleWebSocketMessages(msFlow)
          }

val serverBinding: Future[Http.ServerBinding] = Http().bindAndHandle(websocketRoute, $host, $port)

```

What is the right approach to solving this problem at all?

Thanks!
