[akka-user] Re: Problem detecting Websocket failure

2017-02-21 Thread johannes . rudolph
Hi,

you are applying the `alsoTo` clause to the wrong side of the connection. 
You need to put it on the Sink-side. The way you have written it, the 
`alsoTo` clause waits for your `Source.actorRef` to close the connection.

Try using

singleWebSocketRequest(..., 
Flow[Message].alsoTo(Sink.onComplete(...)).via(yourHandlerFlow))

Johannes

On Wednesday, September 28, 2016 at 3:23:36 PM UTC+2, Alexej Haak wrote:
>
> Hi,
> I have a problem detecting a failing websocket. I already got some help 
> inside the akka issue tracker, so thanks for getting me started there even 
> though it was the wrong place :
>
>  val source = Source.actorRef[Message](bufferSize, OverflowStrategy.fail)
>
>  val flow = Flow
> .fromSinkAndSourceMat(sink, source)(Keep.right)
> .alsoTo(Sink.onComplete(_ => {  // Not working as expected?
>   println("Restarting due to Websocket failure..")
>   println("- \n\n\n\n")
>   restart()
> }))
>
>  val (upgradeResponse, actor) =
> Http().singleWebSocketRequest(
>   WebSocketRequest(
> host + "/console"),
>   flow)
>
> The alsoTo part never triggers, even though the websocket connection 
> closes. I'm Testing it in this setup:
>
> - Play Framework Server with websocket running
> - Client Connects
> - Messaging works
> - Play Framework Server gets restarted
> - Messaging fails and no Client connects
> - Restarting Client manually
> - Messaging works again
>
>
> Best regards :)
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Problem detecting Websocket failure

2017-02-10 Thread Brandon Bradley
Hello!

I also can't get flow.alsoTo(Sink.onComplete(...)) to trigger. The only 
thing that completes when the websocket closes (due to timeout) is the 
materialized Future[Done] from the Flow.

In addition, the pattern to use for reconnection logic becomes unclear 
because the websocket flow is not reusable.

Here 

 
is my own logic for connecting to a websocket. If I add 
websocketFlow.alsoTo(Sink.onComplete(...)), it does not trigger, but 
closed.foreach(_ => throw new Exception("Websocket disconnected.")) does.

Cheers!
Brandon Bradley

On Wednesday, September 28, 2016 at 8:23:36 AM UTC-5, Alexej Haak wrote:
>
> Hi,
> I have a problem detecting a failing websocket. I already got some help 
> inside the akka issue tracker, so thanks for getting me started there even 
> though it was the wrong place :
>
>  val source = Source.actorRef[Message](bufferSize, OverflowStrategy.fail)
>
>  val flow = Flow
> .fromSinkAndSourceMat(sink, source)(Keep.right)
> .alsoTo(Sink.onComplete(_ => {  // Not working as expected?
>   println("Restarting due to Websocket failure..")
>   println("- \n\n\n\n")
>   restart()
> }))
>
>  val (upgradeResponse, actor) =
> Http().singleWebSocketRequest(
>   WebSocketRequest(
> host + "/console"),
>   flow)
>
> The alsoTo part never triggers, even though the websocket connection 
> closes. I'm Testing it in this setup:
>
> - Play Framework Server with websocket running
> - Client Connects
> - Messaging works
> - Play Framework Server gets restarted
> - Messaging fails and no Client connects
> - Restarting Client manually
> - Messaging works again
>
>
> Best regards :)
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Problem detecting Websocket failure

2016-09-29 Thread 'Alexej Haak' via Akka User List


source
  .viaMat(
Http().webSocketClientFlow(
  WebSocketRequest(
host + "/console")
)
  )(Keep.both)
  .alsoTo(Sink.onComplete(_ => {
self ! RestartWebsocket
  }))
  .toMat(sink)(Keep.left)
  .run()

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.