Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

Websocket client add element to source dynamically

$
0
0

Hi all,
i would like to keep multiple websocket client connections, and for each connection i will later send message, what would be the right way of implementing it?
i have actors sharded, and in each of them, i have a websocket connection, like bellow

val request = WebSocketRequest()
val websocketFlow = Http()(classicSystem).webSocketClientFlow(request)
val (((queue, upgradeResponse)), closed) =
      Source.queue[TextMessage](bufferSize = 10, OverflowStrategy.backpressure)
        .viaMat(websocketFlow)(Keep.both)
        .toMat(incoming)(Keep.both)
        .run()(materializer)

And i am using later

queue.offer()

to send new message
It works when there is one connection, however whenever i start a new connection (on another actor sharded), the first actor’s queue just closes

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1362

Trending Articles