[akka-user] Re: akka-http web-socket Frame support question...

2017-02-21 Thread johannes . rudolph
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?
>

-- 
>>  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: akka-http web-socket Frame support question...

2017-02-01 Thread Jan Heise
I have to add that I just found support for automatic pong messages in 

https://github.com/akka/akka-http/blob/master/akka-http-core/src/main/scala/akka/http/impl/engine/ws/FrameHandler.scala

Maybe somebody can give me a hint/help me with injecting control frames?

-- 
>>  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: akka-http web-socket Frame support question...

2017-02-01 Thread Jan Heise
Hi,

I'd like to add, that I'd also be interested in solving this. I'm currently 
developing a server-backend that should support ping/pong frames to conform 
to a specification that specifically references those control frames. I am 
not controlling the development of the clients so having an upper level 
protocol for keep-alives instead is not something that I can do. Ignoring 
the whole thing might be fine in the beginning but eventually, I'll have to 
implement support for ping/pong control frames.

I'd like to reference the following ticket:
https://github.com/akka/akka-http/issues/102

Also, in the source, the necessary opcodes are already mentioned/exist. See:
https://github.com/akka/akka-http/blob/master/akka-http-core/src/main/scala/akka/http/impl/engine/ws/Protocol.scala

Is there any more support regarding this already in the source that I have 
missed?
Any pointers on where I might start adding things myself? Where is the 
place that handles control frames? 
I guess sending a pong message automatically when a ping arrives could be 
handled easily if somebody points me in the right direction.
Injecting ping messages and handling the eventually handling missing pong 
messages might need a bit more thought on behalf of someone better than me. 
But I would like to give it a shot, too.

Best regards,

Jan


Am Donnerstag, 22. Dezember 2016 19:15:03 UTC+1 schrieb Muthu Jayakumar:
>
> 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?
>

-- 
>>  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.