Hi, 
   We already have a websocket sever based on akka-http + stream 10.0.10. 
The same server is leveraged by multiple client. The new version of ws 
client are requesting to have ping/pong based keepalive enable where as the 
old version of client are not.

Hence we have to support both version of clients, So we need an approach to 
atop a ping frame for certain websocket connection based on some request 
header. 
The problem here is we are working with WebSocketDirective which does 
provided access to RawFrame. 

Can anyone please suggest an approach to solve this scenario

Thanks 
-Surya 

On Tuesday, February 21, 2017 at 4:13:52 PM UTC+5:30, 
[email protected] wrote:
>
> Hi,
>
> injecting frames manually is not supported. Not supported means that we 
> don't offer an API that would allow users to do that.
>
> That said, there's an internal API that allows to specify a frame handler 
> directly:
>
>  * You can case the `UpgradeToWebsocket` header to 
> `UpgradeToWebsocketLowLevel`, this allows you to specify a frame handler 
> flow: 
> https://github.com/akka/akka-http/blob/5932237a86a432d623fafb1e84eeeff56d7485fe/akka-http-core/src/main/scala/akka/http/impl/engine/ws/UpgradeToWebSocketLowLevel.scala#L16-L16
>  * The difference between the frame handler and full stack can be 
> basically seen here: 
> https://github.com/akka/akka-http/blob/74148fefccd7d51fe2b18356885a4267b279a73c/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala#L622-L622
>  * Websocket.stack is implemented here: 
> https://github.com/akka/akka-http/blob/5932237a86a432d623fafb1e84eeeff56d7485fe/akka-http-core/src/main/scala/akka/http/impl/engine/ws/WebSocket.scala#L34
>
> As you can see `Websocket.stack` is just a stack of stages. If you wanted 
> inject and intercept control frames you could basically copy the 
> implementation of `stack` and put another custom stage between `masking` 
> and `frameHandling`. Obviously, you need to know what you are doing not to 
> disrupt the usual way things work. Just injecting `Ping` frames and 
> listening to `Pong` frames should be quite simple, though.
>
> All of these classes are `private[akka]` or `private[http]` so you need to 
> implement anything inside of an `akka.http` package in your project.
>
> Good luck and have fun ;)
> Johannes
>
> On Thursday, December 22, 2016 at 7:15:03 PM UTC+1, Muthu Jayakumar wrote:
>>
>> Hello there,
>>
>> I am new to akk-http on writing a web-socket server side code (have 
>> written one using Spray-IO though).  My question is on how I would be able 
>> to use the server-side apis to send other kinds of control-frames? By the 
>> spec @ https://tools.ietf.org/html/rfc6455#page-36
>> Close 
>> Ping 
>> Pong
>> Data -- Text -- Binary
>> The apis have the TextFrame and BinaryFrame part of the Frame covered. I 
>> guess, the PingFrame and PongFrame would be useful to have the server-side 
>> api to help in the "keep-alive" attribute to the connection(as quoted from 
>> the spec: "NOTE: A Ping frame may serve either as a keepalive or as a 
>> means to verify that the remote endpoint is still responsive."). The 
>> same question on CloseFrame may be useful I guess?
>>
>> Please advice,
>> Muthu
>>
>> On a side note...
>> On top of the akka documentation @ 
>> http://doc.akka.io/docs/akka-http/current/scala/http/websocket-support.html, 
>> I found the following article useful in getting Web-Socket to hook-up thru 
>> actor(s) - 
>> https://markatta.com/codemonkey/blog/2016/04/18/chat-with-akka-http-websockets/
>> . 
>> To me the gap is on understanding akka-streams better. Not sure if may be 
>> useful for the documentation to give some hints on how 'server-push' can be 
>> achieved using some code snippet similar to this blog?
>>
>

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/akka-user/95891312-1601-4cdc-87ac-2f1cca16f5f5%40googlegroups.com.

Reply via email to