[akka-user] Re: akka-http web socket issue

2016-07-06 Thread Eric Swenson
I wrote a simple python client:

$ cat ws-test.py
import os
from websocket import create_connection

eiid=os.getenv("EIID")
token=os.getenv("BEARER_TOKEN")
header="Authorization: Bearer %s" % token
ws = create_connection("ws://localhost:9000/ws-connect/%s" % eiid, 
header=[header])
while True:
x = ws.recv()
print(x)

And used it with my server.  It does not disconnect and correctly responds to 
all messages sent by the server.  So that rules out problems with the 
akka-http-based server.  it would appear that the issue is with the akka-http 
client (whose code I got from this web page:

> http://doc.akka.io/docs/akka/2.4.7/scala/http/client-side/websocket-support.html#websocketclientflow
>  
> 
Is there some reason why this code does not work?  As mentioned previously, the 
code connects, retrieves and displays one message sent by the server just after 
connection, and then promptly disconnects the websocket connection.

Are there known issues with client-side web socket support in 2.4.7?

— Eric

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


Re: [akka-user] List of defined rest api's in akka-http based application

2016-07-06 Thread Rafał Krzewski
Please note that route definitions may contain arbitrary code including 
calling methods that produce route fragments.
The only way to introspect the definitions is by using macros, but still I 
don't think it's possible to do correctly it in all cases.

Cheers,
Rafał

W dniu środa, 6 lipca 2016 07:51:34 UTC+2 użytkownik Yadukrishnan K napisał:
>
> Thanks.
>
> I had already read about the akka-http support for swagger. But was 
> wondering, if akka-http itself provide any methods to get the defined 
> api's. 
>
> On Monday, July 4, 2016 at 8:33:53 AM UTC+5:30, Siva Kommuri wrote:
>>
>> Hmm, by introspection - not sure. 
>>
>> You may want to look at swagger support for akka http. The definitions 
>> are explicit though. 
>>
>> Best wishes,
>> Siva on 6+
>>
>> On Jun 29, 2016, at 11:44 PM, Yadukrishnan K  wrote:
>>
>> Thats just akka-http example right. What I want is to get all the defined 
>> urls/services at runtime so that I can make a registry of all the services 
>> I have.
>>
>> On Thursday, June 30, 2016 at 11:29:48 AM UTC+5:30, Siva Kommuri wrote:
>>>
>>> Yes, please see: 
>>> http://doc.akka.io/docs/akka/2.4.7/scala/http/routing-dsl/index.html#long-example
>>>  
>>>
>>>
>>> On June 29, 2016 at 2:35:39 AM, K Yadukrishnan (yada...@gmail.com) 
>>> wrote:
>>>
>>> This may be a very stupid question.
>>>
>>> Is it possible to get all the defined rest services urls in a akka-http 
>>> based application ?
>>>
>>> For eg: Assume that I have Employee Rest, Department Rest, Company Rest 
>>> etc defined, each with say 5 types of urls.
>>>
>>> GET /employees
>>> GET /employees/{id}
>>> POST /employees
>>> GET /departments
>>> GET /departments/{id}
>>>
>>> etc
>>> etc
>>>
>>> In another application(say reporting-engine), I want to list out all the 
>>> possible rest url's for use. So the client can use all the available rest 
>>> services and build the required reports.
>>>
>>> Is there anyway in akka-http, that I can get all the defined urls and 
>>> their Methods ?
>>> --
>>> >> 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+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> -- 
>> >> 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+...@googlegroups.com.
>> To post to this group, send email to akka...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>

-- 
>>  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] akka-http web socket issue

2016-07-06 Thread Eric Swenson
I have a web service, implemented in akka-http, to which I’ve added web socket 
support.  I have an akka-http client that is able to connect to the service and 
receive a single message, thereupon the web socket is, for some reason, 
disconnected.  I do not understand why it becomes disconnected. There is no 
intentional code on the server side that should disconnect the web socket.  On 
the client, I’m using virtually identical to the code found here:

http://doc.akka.io/docs/akka/2.4.7/scala/http/client-side/websocket-support.html#websocketclientflow
 


I’m finding that this code:

val connected = upgradeResponse.flatMap { upgrade =>
  if (upgrade.response.status == StatusCodes.OK) {
Future.successful(Done)
  } else {
throw new RuntimeException(s"Connection failed: ${upgrade.response.status}")
  }
}

upon connection, raises the above RuntimeException.  The value of 
upgrade.response.status is "101 Switching Protocols”. I do receive one message 
from server-to-client and displayed by the client before the “closed” Future is 
completed:

val (upgradeResponse, closed) =
  outgoing
.viaMat(webSocketFlow)(Keep.right) // keep the materialized 
Future[WebSocketUpgradeResponse]
.toMat(incoming)(Keep.both) // also keep the Future[Done]
.run()
When the closed Future completes, this code is executed:

closed.foreach(_ => println("closed"))
and I see this “closed” message displayed.  However, before it is displayed, I 
do get a message sent by the service to the client.

My questions:  1) isn’t the “101 Switching Protocols” status expected?  Why is 
that not handled in the if clause of the upgrade response handling logic?  I 
did change the conditional to:

if (upgrade.response.status == StatusCodes.OK || upgrade.response.status == 
StatusCodes.SwitchingProtocols)
But while that prevents the runtime exception, the connection still 
automatically closes after receiving the first message.

On the server side, I have logic that looks like this:

class WebSocketConnection(experimentInstanceId: String, httpActorSystem: 
ActorSystem, clusterActorSystem: ActorSystem) {
  
  private[this] val experimentInstanceRegion = 
ClusterSharding(clusterActorSystem).shardRegion(ExperimentInstance.shardName)

  def websocketFlow: Flow[Message, Message, _] =
Flow.fromGraph(
  GraphDSL.create(Source.actorRef[WsMessage](bufferSize = 5, 
OverflowStrategy.fail)) { implicit builder =>
wsMessageSource => //source provided as argument

  // flow used as input from web socket
  val fromWebsocket = builder.add(
Flow[Message].collect {
  case TextMessage.Strict(txt) =>
println(s"txt=$txt")
WsIncomingMessage(experimentInstanceId, txt)
})

  // flow used as output, it returns Messages
  val backToWebsocket = builder.add(
Flow[WsMessage].map {
  case WsMessage(author, text) => TextMessage(s"[$author]: $text")
}
  )

  // send messages to the actor, if send also 
Disconnected(experimentInstanceId) before stream completes.
  val actorSink = 
Sink.actorRef[WebSocketEvent](experimentInstanceRegion, 
WsDisconnected(experimentInstanceId))

  // merges both pipes
  val merge = builder.add(Merge[WebSocketEvent](2))

  val actorAsSource = builder.materializedValue.map(actor => 
WsConnected(experimentInstanceId, actor))

  fromWebsocket ~> merge.in(0)

  actorAsSource ~> merge.in(1)

  merge ~> actorSink

  wsMessageSource ~> backToWebsocket

  // expose ports

  FlowShape(fromWebsocket.in, backToWebsocket.outlet)
  })

  def sendMessage(message: WsMessage): Unit = experimentInstanceRegion ! message
}
In the actor associated with the experimentInstanceRegion (e.g. a cluster 
sharing region), I see log messages indicating a WsConnected message is 
received.  And then shortly after, I see that the WsDisconnected message is 
received.  

I haven’t touched the web socket support logic in quite some time.  However, 
this all used to work — in other words, the client would stay active and 
display messages received from the server, and the server would continue 
sending messages to the client over the web socket connection until the client 
disconnected (on purpose).  This was all working in akka 2.3 and may have 
broken when I upgraded to the various 2.4 releases and is still broken using 
2.4.7.  

Any suggestions on how to debug this?  Any reason for the auto-disconnection?  
And what about the 101 Switching Protocols handling (mentioned above)?

Thanks. — Eric

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

Re: [akka-user] Re: Directive to handle Future

2016-07-06 Thread Maatary Okouya
Oh thanks

On Wed, Jul 6, 2016 at 3:33 PM,  wrote:

>
> http://doc.akka.io/docs/akka/2.4.7/scala/http/routing-dsl/directives/future-directives/onComplete.html#oncomplete
>
>
> Em quarta-feira, 6 de julho de 2016 16:23:18 UTC-3, Maatary Okouya
> escreveu:
>>
>>
>> Hi,
>>
>> instead of
>>
>>
>>1. val route =
>>2. path("hello") {
>>3. get {
>>4. complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "Say
>>hello to akka-http"))
>>5. }
>>6. }
>>
>> I would like a directive to which i can pass a future.
>>
>> I need to call another service compute some value and then return the
>> result as a future that i can then pass to the directive such as complete
>> here.
>>
>>
>> --
> >> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/lWMsRn6Es3s/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

-- 
>>  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: Directive to handle Future

2016-07-06 Thread matheuslima
http://doc.akka.io/docs/akka/2.4.7/scala/http/routing-dsl/directives/future-directives/onComplete.html#oncomplete

Em quarta-feira, 6 de julho de 2016 16:23:18 UTC-3, Maatary Okouya escreveu:
>
>
> Hi, 
>
> instead of 
>
>
>1. val route =
>2. path("hello") {
>3. get {
>4. complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "Say hello 
>to akka-http"))
>5. }
>6. }
>
> I would like a directive to which i can pass a future. 
>
> I need to call another service compute some value and then return the 
> result as a future that i can then pass to the directive such as complete 
> here. 
>
>
>

-- 
>>  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] Directive to handle Future

2016-07-06 Thread Maatary Okouya

Hi, 

instead of 


   1. val route =
   2. path("hello") {
   3. get {
   4. complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "Say hello 
   to akka-http"))
   5. }
   6. }

I would like a directive to which i can pass a future. 

I need to call another service compute some value and then return the 
result as a future that i can then pass to the directive such as complete 
here. 


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


Re: [akka-user] Re: [ANNOUNCE] Announcing the new Akka Team Blog (Let it Crash!)

2016-07-06 Thread Konrad Malawski
I added some rel links, that's likely it.
Thanks for rasing the issue :)
On Jul 6, 2016 19:59, "Andrew Gaydenko"  wrote:

> Thanks!
> At that moment for some reason Firefox hasn't found the refs. Now it does.
> Sorry for noise.
>
> --
> >> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/_t8E0khAnJ8/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

-- 
>>  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: [ANNOUNCE] Announcing the new Akka Team Blog (Let it Crash!)

2016-07-06 Thread Andrew Gaydenko
Thanks! 
At that moment for some reason Firefox hasn't found the refs. Now it does. 
Sorry for noise.

-- 
>>  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: [ANNOUNCE] Announcing the new Akka Team Blog (Let it Crash!)

2016-07-06 Thread konrad
There is RSS / Atom.
Usually if you point an RSS reader to such page it just figures it out.

RSS: http://blog.akka.io/rss
Atom: http://blog.akka.io/atom.xml

I'll add some icons for it

-- Konrad


On Wednesday, July 6, 2016 at 2:08:02 PM UTC+2, Konrad Malawski wrote:
>
> Dear hakkers,
> We're very excited to be able to introduce the new and fresh Akka Team 
> Blog!
>
> It's available here: blog.akka.io
>
> And we've already kick started it with 2 posts:
> - An Akka Community Update (July 2016) 
>  in 
> which we discuss the way forward for various Akka related projects, and our 
> ambitions to grow the community even even stronger than it is now (you're 
> all awesome, thanks!)
> - And the first in a series of upcoming "internals and details" posts 
> about Akka Streams: Threading & Concurrency in Akka Streams Explained 
> (part I) 
> 
>  
>
> The blog will mostly feature technical high quality content straight from 
> the core team.
> We also have plans to keep blogging on it as part of our routine, so 
> expect some "feature spotlights" and other posts in the future.
>
>
> The blog's sources are hosted here: http://github.com/akka/blog so if you 
> see anything that needs fixing please let us know there or submit a PR 
> right away.
>
>
> Happy hakking!
>
> -- 
> Cheers,
> Konrad 'ktoso' Malawski
> Akka  @ Lightbend 
>

-- 
>>  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: [ANNOUNCE] Announcing the new Akka Team Blog (Let it Crash!)

2016-07-06 Thread Andrew Gaydenko
Great! Any chance for RSS?

-- 
>>  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] [ANNOUNCE] Announcing the new Akka Team Blog (Let it Crash!)

2016-07-06 Thread Konrad Malawski
Dear hakkers,
We're very excited to be able to introduce the new and fresh Akka Team Blog!

It's available here: blog.akka.io

And we've already kick started it with 2 posts:
- An Akka Community Update (July 2016)
 in
which we discuss the way forward for various Akka related projects, and our
ambitions to grow the community even even stronger than it is now (you're
all awesome, thanks!)
- And the first in a series of upcoming "internals and details" posts about
Akka Streams: Threading & Concurrency in Akka Streams Explained (part I)



The blog will mostly feature technical high quality content straight from
the core team.
We also have plans to keep blogging on it as part of our routine, so expect
some "feature spotlights" and other posts in the future.


The blog's sources are hosted here: http://github.com/akka/blog so if you
see anything that needs fixing please let us know there or submit a PR
right away.


Happy hakking!

-- 
Cheers,
Konrad 'ktoso' Malawski
Akka  @ Lightbend 

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