[akka-user] Re: Akka Cluster + Leveldb : Persistence failure when replaying events for ...

2016-07-20 Thread Manoj Santhakumaran
Hi All,

Today I analyzed by consuming cluster events.
When first node is down, I got only an UnreachableMember event. I was 
expecting a MemberRemoved or MemberExited event after UnreachableMember. Is 
that correct? I didn't get either of them.

Is this because I have only two nodes in the cluster and no one alive in 
first node to send out a MemberRemoved or MemberExited?

I have attached here the logs of node 2 when node 1 goes down.

Any suggestions/pointers on how we can enable proper fail-over when primary 
node crashed?

Thanks and regards,
Manoj


On Tuesday, 19 July 2016 13:05:55 UTC-7, Manoj Santhakumaran wrote:
>
> Hi All,
>
> I'm facing following problem with my Akka cluster environment which has 
> two nodes, and Akka persistence using leveldb-journal.
>
> Both nodes are started with "ClusterSingletonManager" and 
> "ClusterSingletonProxy". My "UntypedPersistentActor" is started as 
> "ClusterClientReceptionist". In my first node, I'm starting the 
> "SharedLeveldbStore" and setting that by 
> "SharedLeveldbJournal.setStore(...)" call. But in second node, I'm only 
> setting "SharedLeveldbJournal.setStore(..)" of the first node when starts 
> up.
>
> When both nodes are running, everything works fine.
>
> But when the first node died, I was expecting the second node takes up the 
> charge and replay the persisted events. But it is throwing following 
> exception in the logs and became zombie (process is running but not doing 
> its job). I noticed that the "postStop" event handler of my 
> "UntypedPersistentActor" is called after this error.
>
> ERROR | 2016-07-19 11:37:24 | 
> [ClusterSystem-akka.actor.default-dispatcher-18] ? - 
> [sourceThread=ClusterSystem-akka.actor.default-dispatcher-18, 
> sourceActorSystem=ClusterSystem, 
> akkaSource=akka.tcp://ClusterSystem@hostname2:2552/user/master/singleton, 
> akkaTimestamp=18:37:24.195UTC] - Persistence failure when replaying events 
> for persistenceId [master]. Last known sequence number [0]
> akka.pattern.CircuitBreaker$$anon$1: Circuit Breaker Timed out.
>
> My environment : Play (2.4.0), Akka (2.4.4), Akka Persistence (2.3.9), 
> Leveldb (0.7), Leveldb-Jni (1.8)
>
> My application.conf have following cluster configuration.
>
>   extensions = ["akka.cluster.client.ClusterClientReceptionist"]
>   cluster {
>   seed-nodes = [
> "akka.tcp://ClusterSystem@hostname1:2551",
> "akka.tcp://ClusterSystem@hostname2:2552"]
>   }
>   persistence {
> journal.plugin = "akka.persistence.journal.leveldb-shared"
> journal.leveldb-shared.store {
>   # This is non-prod
>   native = off
>   dir = "/shared-vol1/leveldb-journal"
> }
> snapshot-store.plugin = "akka.persistence.snapshot-store.local"
> snapshot-store.local.dir = "target/snapshots"
>   }
>
> I appreciate any solution/suggestion/pointer to resolve this issue.
>
> Thank you very much.
> Manoj
>
>

-- 
>>  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.
DEBUG | 2016-07-20 15:21:28 | [ClusterSystem-akka.actor.default-dispatcher-5] ? 
- [sourceThread=ClusterSystem-akka.remote.default-remote-dispatcher-10, 
sourceActorSystem=ClusterSystem, 
akkaSource=akka.tcp://ClusterSystem@hostname2:2552/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FClusterSystem%40hostname1%3A2551-0/endpointWriter,
 akkaTimestamp=22:21:28.976UTC] - received local message RemoteMessage: 
[ActorSelectionMessage(Heartbeat(akka.tcp://ClusterSystem@hostname1:2551),Vector(system,
 cluster, heartbeatReceiver),false)] to 
[Actor[akka://ClusterSystem/]]<+[akka://ClusterSystem/] from 
[Actor[akka.tcp://ClusterSystem@hostname1:2551/system/cluster/core/daemon/heartbeatSender#1109227863]()]
DEBUG | 2016-07-20 15:21:28 | [ClusterSystem-akka.actor.default-dispatcher-2] ? 
- [sourceThread=ClusterSystem-akka.remote.default-remote-dispatcher-10, 
sourceActorSystem=ClusterSystem, 
akkaSource=akka.tcp://ClusterSystem@hostname2:2552/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FClusterSystem%40hostname1%3A2551-0/endpointWriter,
 akkaTimestamp=22:21:28.976UTC] - sending message RemoteMessage: 
[HeartbeatRsp(UniqueAddress(akka.tcp://ClusterSystem@hostname2:2552,-432593112))]
 to 
[Actor[akka.tcp://ClusterSystem@hostname1:2551/system/cluster/core/daemon/heartbeatSender#1109227863]]<+[akka.tcp://ClusterSystem@hostname1:2551/system/cluster/core/daemon/heartbeatSender]
 from 

[akka-user] Configurable parallelism/elastic groupBy

2016-07-20 Thread Richard Rodseth
I'm sure I've asked this before in numerous ways, but it's still an issue
for me.

I have an ETL stream that reads per-channel data and writes it to a
destination without backpressure. Within a channel, order of writes must be
preserved. So I want parallelism between channels, but not within.

If I groupBy by channel, I can't control the degree of parallelism  and the
destination is overwhelmed.
Should I make an ActorSubscriber for the write, that backpressures (based
on an integer value) and use alsoTo on the SubFlow?

Any way to achieve this with standard components?

-- 
>>  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] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Konrad Malawski
I don't know what your actor publisher was doing inside there. But yeah,
this is even better if you can get away without implementing custom stages.

On Jul 20, 2016 16:51, "Jakub Liska"  wrote:

> There seems to be a third alternative to ActorPublisher :
>
>  Source.actorRef[User.OutgoingMessage](10, OverflowStrategy.fail).
> mapMaterializedValue
>
> the actorRef can be passed to a different Actor that would feed it
> messages and it would all behave like ActorPublisher, right?
>
> On Wednesday, July 20, 2016 at 4:21:35 PM UTC+2, Konrad Malawski wrote:
>>
>> Glad you resolved it.
>> Related hint is that one really really shouldn't be using ActorPublisher,
>> you should build stages from GraphStage instead,
>> the reason is that a) ActorPublisher is not fusable b) it's really hard
>> to actually implement a *correct* Publisher (even with ActorPublisher's
>> help).
>>
>> Happy hakking.,
>>
>> --
>> Konrad `ktoso` Malawski
>> Akka  @ Lightbend 
>>
>> On 20 July 2016 at 16:19:58, Jakub Liska (liska...@gmail.com) wrote:
>>
>> RESOLVED :
>>
>> I found a way to create Source and consequently ActorPublisher from
>> ActorRef, so that I can obtain the ActorRef upfront, so instead of :
>>
>> val stateChangeSource: Source[PipelineState, ActorRef] = Source.
>> actorPublisher[PipelineState](StateChangePublisher.props)
>>
>> I do :
>>
>> val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
>> PipelineState](stateChangePublisherRef)
>> val stateChangeSource = Source.fromPublisher(stateChangePublisher)
>>
>> And I can send messages to stateChangePublisherRef and push them to
>> Browser...
>>
>> On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote:
>>>
>>> Could you provide a sample snippet that we could help out with?
>>> Context helps to get quicker help.
>>>
>>> --
>>> Konrad `ktoso` Malawski
>>> Akka  @ Lightbend 
>>>
>>> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com) wrote:
>>>
>>> hey,
>>>
>>> I hit a deadend with combination of Websockets and ActorPublisher
>>> because the TextMessage expects Source and one can obtain the underlying
>>> ActorRef from ActorPublisher only by materializing it :
>>>
>>>
>>> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>>>
>>> Theoretically one could look it up but then there is a question "when"
>>> it becomes materialized :-/
>>> --
>>> >> 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.
>

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

Re: [akka-user] Creating Actor w/ Props having Value Class Argument(s)

2016-07-20 Thread Konrad Malawski
This basically demonstrates the core of the problem:

scala> class Meter(val m: Int) extends AnyVal
defined class Meter
// in runtime you have *no way* to check if it's an AnyVal extending
class or not. We would have to use macros. (scala reflection is a bit
iffy...)

scala> val m = new Meter(12)
m: Meter = Meter@c

scala> class Act(m: Meter)
defined class Act

scala> classOf[Act].getDeclaredConstructors.head
res23: java.lang.reflect.Constructor[_] = public Act(int)
// constructor takes int as you can see
// it is the ONLY constructor this class has - you can't pass in a
Meter instance.

scala> classOf[Act].getDeclaredConstructors.head.newInstance(new Integer(12))
res24: Any = Act@572db5ee

scala> classOf[Act].getDeclaredConstructors.head.newInstance(new
Meter(12).asInstanceOf[Object])
java.lang.IllegalArgumentException: argument type mismatch
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  ... 32 elided
// NOPE.


// because if effectively is exactly the same as:
scala> class Act2(m: Int)
defined class Act2

scala> classOf[Act2].getDeclaredConstructors.head
res27: java.lang.reflect.Constructor[_] = public Act2(int)

scala>  classOf[Act].getDeclaredConstructors.head.newInstance(new Integer(12))
res28: Any = Act@50f65fe0

scala>  classOf[Act].getDeclaredConstructors.head.newInstance(new
Meter(12).asInstanceOf[Object])
java.lang.IllegalArgumentException: argument type mismatch
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  ... 32 elided


So we’d be forced into guesswork about “hmmm! it has one field, maybe if we
take the field out of that instance it will work!”. Which is weird, so we
choose not to do this.

If you have a solution to this problem I’d love to hear it :-)



-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 17:29:15, Kevin Meredith (kevin.m.mered...@gmail.com)
wrote:

Hi Konrad -

Could you please give me an example that demonstrates the "so we can't ..."?

>AnyVal is a Scala compiler optimisation, so we can't figure out the right
constructor (always / safely) in runtime.

Thanks

On Wednesday, July 20, 2016 at 9:44:33 AM UTC-4, Konrad Malawski wrote:
>
> Because the type (wrapper) is not there at runtime.
> AnyVal is a Scala compiler optimisation, so we can't figure out the right
> constructor (always / safely) in runtime.
>
> A resolution would be to "if thing has one field, and that value matches
> we use that field" which could lead to very weird behaviour sometimes.
>
> --
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 15:40:08, Kevin Meredith (kevin.m@gmail.com
> ) wrote:
>
> Looking at the Akka docs
>  for creating an
> Actor:
>
> The recommended approach to create the actor Props is not supported for
> cases when the actor constructor takes value classes as arguments.
>
> Please explain the "is not supported ..." reason.
>
> Per
> http://stackoverflow.com/questions/38400433/function-to-accept-any-type-but-anyval,
> I'm curious.
>
> Thanks.
> --
> >> 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.

-- 
>>  Read the docs: 

Re: [akka-user] Creating Actor w/ Props having Value Class Argument(s)

2016-07-20 Thread Kevin Meredith
Hi Konrad -

Could you please give me an example that demonstrates the "so we can't ..."?

>AnyVal is a Scala compiler optimisation, so we can't figure out the right 
constructor (always / safely) in runtime.

Thanks

On Wednesday, July 20, 2016 at 9:44:33 AM UTC-4, Konrad Malawski wrote:
>
> Because the type (wrapper) is not there at runtime.
> AnyVal is a Scala compiler optimisation, so we can't figure out the right 
> constructor (always / safely) in runtime.
>
> A resolution would be to "if thing has one field, and that value matches 
> we use that field" which could lead to very weird behaviour sometimes.
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 15:40:08, Kevin Meredith (kevin.m@gmail.com 
> ) wrote:
>
> Looking at the Akka docs 
>  for creating an 
> Actor:
>
> The recommended approach to create the actor Props is not supported for 
> cases when the actor constructor takes value classes as arguments.
>
> Please explain the "is not supported ..." reason.
>
> Per 
> http://stackoverflow.com/questions/38400433/function-to-accept-any-type-but-anyval,
>  
> I'm curious.
>
> Thanks.
> --
> >> 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 MicroServices Communication

2016-07-20 Thread Maatary Okouya
Hi, 

as of now what is that people usually do when exposing microservices: 


1 - Do you communicate via REST (which can easily be turn somewhat async). 


2 - Do you rather use Binary communication ? 



The point is if microservices allow full blown interoperability by 
encapsulating how the the microservice is done, using akka/scala/java, 
Python, Java with other framework, and so on, how one reconcile that with 
AKKA binary communication between actors. I wonder what is the practical 
vision around micro-services. 

Even if it is not J2EE containers, it seems like in practices, one will 
stick to AKKA infrastructure to support and run all the microservices. 
 However if one as a set of microservices to be build by another team that 
works in another languages, then we have a problem. How to ensure 
communication between those services ?


I find the API GateWay approach to be a hassle that add complexity, but i 
may be wrong. 


3 - Finally what is the best way to expose an actor or a set of actor 
behind a rooter, as one microservice to the outside world, using Json Rest. 
So far i would use AKKA-HTTP where i would define all my endpoint, to the 
microservices, and then use actors on the back, that actually do the work. 
However in this configuration, i have a hard time to reconcile the idea of 
bounded context and so on. It seems to amount to the API GateWay. I don't 
see how to expose multiple independent Microservices, with their own 
interface to the world, without using one central interface (webserver) 
like akka http. 

3.1 - Shall i deploy multiple instance of Akka HTTP independently, if i 
want to have fully independent microservices ?  I think it would be great 
to precise what it is important to isolate. The service code, the server, 
http endpoint definition, and so son. 


4 - Is Akka HTTP compatible with AKKA Clustering ?

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

2016-07-20 Thread Maatary Okouya
Hi, 

as of now what is that people usually do when exposing microservices: 


1 - Do you communicate via REST (which can easily turn somewhat async). 


2 - Do you rather use Binary communication ? 



The point is if microservices allow full blown interoperability by 
encapsulating how the the microservice is done, using akka/scala/java, 
Python, Java with other framework, and so on, how one reconcile that with 
AKKA binary communication between actors. I wonder what is the practical 
vision around micro-services. 

Even if it is not J2EE containers, it seems like in practices, one will 
stick to AKKA infrastructure to support and run all the microservices. 
 However if one as a set of microservices to be build by another team that 
works in another languages, then we have a problem. 


I find the API GateWay approach to be a hassle that add complexity, but i 
may be wrong. 


3 - Finally what is the best way to expose an actor or a set of actor 
behind a rooter, as one microservice to the outside world, using Json Rest. 
So far i would use AKKA-HTTP where i would define all my endpoint, to the 
microservices, and then use actors on the back, that actually do the work. 
However in this configuration, i have a hard time to reconcile the idea of 
bounded context and so on. It amount to the API GateWay. I don't see how to 
expose multiple independent Microservices, with their own interface to the 
world, without using one central interface like akka http. 

3.1 - Shall i deploy multiple instance of Akka HTTP independently, if i 
want to have fully independent microservices ?


4 - Is Akka HTTP compatible with AKKA Clustering ?

-- 
>>  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] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Jakub Liska
There seems to be a third alternative to ActorPublisher :

 Source.actorRef[User.OutgoingMessage](10, OverflowStrategy.fail).
mapMaterializedValue

the actorRef can be passed to a different Actor that would feed it messages 
and it would all behave like ActorPublisher, right?

On Wednesday, July 20, 2016 at 4:21:35 PM UTC+2, Konrad Malawski wrote:
>
> Glad you resolved it.
> Related hint is that one really really shouldn't be using ActorPublisher, 
> you should build stages from GraphStage instead,
> the reason is that a) ActorPublisher is not fusable b) it's really hard to 
> actually implement a *correct* Publisher (even with ActorPublisher's help).
>
> Happy hakking.,
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 16:19:58, Jakub Liska (liska...@gmail.com ) 
> wrote:
>
> RESOLVED : 
>
> I found a way to create Source and consequently ActorPublisher from 
> ActorRef, so that I can obtain the ActorRef upfront, so instead of :
> 
> val stateChangeSource: Source[PipelineState, ActorRef] = Source.
> actorPublisher[PipelineState](StateChangePublisher.props)
>
> I do :
>
> val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
> PipelineState](stateChangePublisherRef)
> val stateChangeSource = Source.fromPublisher(stateChangePublisher)
>
> And I can send messages to stateChangePublisherRef and push them to 
> Browser... 
>
> On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote: 
>>
>> Could you provide a sample snippet that we could help out with?
>> Context helps to get quicker help.
>>
>> -- 
>> Konrad `ktoso` Malawski
>> Akka  @ Lightbend 
>>
>> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com) wrote:
>>
>> hey,  
>>
>> I hit a deadend with combination of Websockets and ActorPublisher because 
>> the TextMessage expects Source and one can obtain the underlying ActorRef 
>> from ActorPublisher only by materializing it :
>>  
>>
>> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>>
>> Theoretically one could look it up but then there is a question "when" it 
>> becomes materialized :-/
>> --
>> >> 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.


Re: [akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Jakub Liska
RESOLVED : 

I found a way to create Source and consequently ActorPublisher from 
ActorRef, so that I can obtain the ActorRef upfront, so instead of :
   
val stateChangeSource: Source[PipelineState, ActorRef] = Source.
actorPublisher[PipelineState](StateChangePublisher.props)

I do :

val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
PipelineState](stateChangePublisherRef)
val stateChangeSource = Source.fromPublisher(stateChangePublisher)

And I can send messages to stateChangePublisherRef and push them to 
Browser... 

On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote:
>
> Could you provide a sample snippet that we could help out with?
> Context helps to get quicker help.
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com ) 
> wrote:
>
> hey,  
>
> I hit a deadend with combination of Websockets and ActorPublisher because 
> the TextMessage expects Source and one can obtain the underlying ActorRef 
> from ActorPublisher only by materializing it :
>  
>
> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>
> Theoretically one could look it up but then there is a question "when" it 
> becomes materialized :-/
> --
> >> 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.


Re: [akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Konrad Malawski
Glad you resolved it.
Related hint is that one really really shouldn't be using ActorPublisher,
you should build stages from GraphStage instead,
the reason is that a) ActorPublisher is not fusable b) it's really hard to
actually implement a *correct* Publisher (even with ActorPublisher's help).

Happy hakking.,

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 16:19:58, Jakub Liska (liska.ja...@gmail.com) wrote:

RESOLVED :

I found a way to create Source and consequently ActorPublisher from
ActorRef, so that I can obtain the ActorRef upfront, so instead of :

val stateChangeSource: Source[PipelineState, ActorRef] = Source.
actorPublisher[PipelineState](StateChangePublisher.props)

I do :

val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
PipelineState](stateChangePublisherRef)
val stateChangeSource = Source.fromPublisher(stateChangePublisher)

And I can send messages to stateChangePublisherRef and push them to
Browser...

On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote:
>
> Could you provide a sample snippet that we could help out with?
> Context helps to get quicker help.
>
> --
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com )
> wrote:
>
> hey,
>
> I hit a deadend with combination of Websockets and ActorPublisher because
> the TextMessage expects Source and one can obtain the underlying ActorRef
> from ActorPublisher only by materializing it :
>
>
> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>
> Theoretically one could look it up but then there is a question "when" it
> becomes materialized :-/
> --
> >> 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.

-- 
>>  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] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Konrad Malawski
Could you provide a sample snippet that we could help out with?
Context helps to get quicker help.

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 16:03:30, Jakub Liska (liska.ja...@gmail.com) wrote:

hey,

I hit a deadend with combination of Websockets and ActorPublisher because
the TextMessage expects Source and one can obtain the underlying ActorRef
from ActorPublisher only by materializing it :

https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30

Theoretically one could look it up but then there is a question "when" it
becomes materialized :-/
--
>> 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.

-- 
>>  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] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Jakub Liska
hey, 

I hit a deadend with combination of Websockets and ActorPublisher because 
the TextMessage expects Source and one can obtain the underlying ActorRef 
from ActorPublisher only by materializing it :
 
https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30

Theoretically one could look it up but then there is a question "when" it 
becomes materialized :-/

-- 
>>  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] Creating Actor w/ Props having Value Class Argument(s)

2016-07-20 Thread Konrad Malawski
Because the type (wrapper) is not there at runtime.
AnyVal is a Scala compiler optimisation, so we can't figure out the right
constructor (always / safely) in runtime.

A resolution would be to "if thing has one field, and that value matches we
use that field" which could lead to very weird behaviour sometimes.

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 15:40:08, Kevin Meredith (kevin.m.mered...@gmail.com)
wrote:

Looking at the Akka docs
 for creating an
Actor:

The recommended approach to create the actor Props is not supported for
cases when the actor constructor takes value classes as arguments.

Please explain the "is not supported ..." reason.

Per
http://stackoverflow.com/questions/38400433/function-to-accept-any-type-but-anyval,
I'm curious.

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

-- 
>>  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] Creating Actor w/ Props having Value Class Argument(s)

2016-07-20 Thread Kevin Meredith


Looking at the Akka docs 
 for creating an 
Actor:

The recommended approach to create the actor Props is not supported for 
cases when the actor constructor takes value classes as arguments.

Please explain the "is not supported ..." reason.

Per 
http://stackoverflow.com/questions/38400433/function-to-accept-any-type-but-anyval,
 
I'm curious.

Thanks.

-- 
>>  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: Make HTTPS request using akka-http to jenkins server

2016-07-20 Thread Konrad Malawski
Pretty sure there's a stack trace there though?
What happens on default settnigs – dont manually set the JVM default
context.

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 14:13:39, Ajinkya Shukla (ajinkyashukl...@gmail.com)
wrote:

I get the following exception in DEBUG mode.

disconnected after javax.net.ssl.SSLHandshakeException: General SSLEngine
problem

On Wednesday, July 20, 2016 at 8:01:04 AM UTC-4, Ajinkya Shukla wrote:
>
> How can i make the following HTTPS request using akka-http to a jenkins
> server?
>
> curl -v -k --user "$USERNAME:$API_TOKEN" https://HOSTNAME.com/api/json
>
> The curl produces the following HTTPS request:
>
> Connected to HOST.com
> * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
> * Server certificate: Default Company Ltd
> * Server auth using Basic with user 'USERNAME'
> > GET /api/json HTTP/1.1
> > Host: HOSTNAME
> > Authorization: Basic API_TOKEN
> > User-Agent: curl/7.43.0
> > Accept: */*
>
> However I am not able to make the above request using akka-http. I get a
> SSL certificate error. Here is my code:
>
>
> import javax.net.ssl.SSLContext
>
> import akka.actor.{Actor, ActorLogging, ActorSystem}
> import akka.http.scaladsl.model._
> import akka.http.scaladsl.model.headers.{Authorization,
> BasicHttpCredentials}
> import akka.http.scaladsl.{Http, HttpsConnectionContext}
> import akka.stream.{ActorMaterializer, ActorMaterializerSettings,
> Materializer}
> import akka.util.ByteString
> import com.typesafe.sslconfig.akka.AkkaSSLConfig
> import com.typesafe.sslconfig.ssl.{SSLConfigSettings, SSLParametersConfig}
>
> import scala.concurrent.Future
>
> class Main extends Actor
>   with ActorLogging {
>
>   import akka.pattern.pipe
>   import context.dispatcher
>
>   implicit val system = ActorSystem("HelloSystem")
>
>   final implicit val materializer: ActorMaterializer =
> ActorMaterializer(ActorMaterializerSettings(context.system))
>
>   val modernHttpsConnectionContext: HttpsConnectionContext = new
> HttpsConnectionContext(
> SSLContext.getDefault,
> enabledProtocols = Some("TLSv1.2" :: "TLSv1.1" :: Nil)
>   )
>
>   class HttpClientSingleCustomHttps(connectionContext:
> HttpsConnectionContext)
>(implicit val system: ActorSystem, val
> mat: Materializer) {
> def sendHttpReq(req: HttpRequest): Future[HttpResponse] =
>   Http().singleRequest(req, connectionContext =
> connectionContext).pipeTo(self)
>   }
>
>   override def preStart() = {
> log.info("Making request")
> val client = new
> HttpClientSingleCustomHttps(modernHttpsConnectionContext)
> val jenkinsRequest: HttpRequest = HttpRequest(
>   uri = "https://HOSTNAME.com/api/json;,
>   headers = List(
> Authorization(BasicHttpCredentials("USERNAME","PASSWORD"))
>   )
> )
> client.sendHttpReq(jenkinsRequest)
>   }
>
>   def receive = {
> case HttpResponse(StatusCodes.OK, headers, entity, _) =>
>   log.info("Got response, body: " +
> entity.dataBytes.runFold(ByteString(""))(_ ++ _))
> case HttpResponse(code, _, _, _) =>
>   log.info("Request failed, response code: " + code)
>   }
>
> }
>
> --
>> 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.

-- 
>>  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: Make HTTPS request using akka-http to jenkins server

2016-07-20 Thread Ajinkya Shukla
I get the following exception in DEBUG mode.

disconnected after javax.net.ssl.SSLHandshakeException: General SSLEngine 
problem

On Wednesday, July 20, 2016 at 8:01:04 AM UTC-4, Ajinkya Shukla wrote:
>
> How can i make the following HTTPS request using akka-http to a jenkins 
> server?
>
> curl -v -k --user "$USERNAME:$API_TOKEN" https://HOSTNAME.com/api/json
>
> The curl produces the following HTTPS request:
>
> Connected to HOST.com
> * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
> * Server certificate: Default Company Ltd
> * Server auth using Basic with user 'USERNAME'
> > GET /api/json HTTP/1.1
> > Host: HOSTNAME
> > Authorization: Basic API_TOKEN
> > User-Agent: curl/7.43.0
> > Accept: */*
>
> However I am not able to make the above request using akka-http. I get a 
> SSL certificate error. Here is my code:
>
>
> import javax.net.ssl.SSLContext
>
> import akka.actor.{Actor, ActorLogging, ActorSystem}
> import akka.http.scaladsl.model._
> import akka.http.scaladsl.model.headers.{Authorization, 
> BasicHttpCredentials}
> import akka.http.scaladsl.{Http, HttpsConnectionContext}
> import akka.stream.{ActorMaterializer, ActorMaterializerSettings, 
> Materializer}
> import akka.util.ByteString
> import com.typesafe.sslconfig.akka.AkkaSSLConfig
> import com.typesafe.sslconfig.ssl.{SSLConfigSettings, SSLParametersConfig}
>
> import scala.concurrent.Future
>
> class Main extends Actor
>   with ActorLogging {
>
>   import akka.pattern.pipe
>   import context.dispatcher
>
>   implicit val system = ActorSystem("HelloSystem")
>
>   final implicit val materializer: ActorMaterializer = 
> ActorMaterializer(ActorMaterializerSettings(context.system))
>
>   val modernHttpsConnectionContext: HttpsConnectionContext = new 
> HttpsConnectionContext(
> SSLContext.getDefault,
> enabledProtocols = Some("TLSv1.2" :: "TLSv1.1" :: Nil)
>   )
>
>   class HttpClientSingleCustomHttps(connectionContext: 
> HttpsConnectionContext)
>(implicit val system: ActorSystem, val 
> mat: Materializer) {
> def sendHttpReq(req: HttpRequest): Future[HttpResponse] =
>   Http().singleRequest(req, connectionContext = 
> connectionContext).pipeTo(self)
>   }
>
>   override def preStart() = {
> log.info("Making request")
> val client = new 
> HttpClientSingleCustomHttps(modernHttpsConnectionContext)
> val jenkinsRequest: HttpRequest = HttpRequest(
>   uri = "https://HOSTNAME.com/api/json;,
>   headers = List(
> Authorization(BasicHttpCredentials("USERNAME","PASSWORD"))
>   )
> )
> client.sendHttpReq(jenkinsRequest)
>   }
>
>   def receive = {
> case HttpResponse(StatusCodes.OK, headers, entity, _) =>
>   log.info("Got response, body: " + 
> entity.dataBytes.runFold(ByteString(""))(_ ++ _))
> case HttpResponse(code, _, _, _) =>
>   log.info("Request failed, response code: " + code)
>   }
>
> }
>
>

-- 
>>  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] Make HTTPS request using akka-http to jenkins server

2016-07-20 Thread Konrad Malawski
Please read:
http://doc.akka.io/docs/akka/2.4.8/scala/http/client-side/client-https-support.html#clientsidehttps
and: http://typesafehub.github.io/ssl-config/

Note that you're using SSLContext.getDefault, pretty sure that's not a good
idea for you.

Also, what's the error? Please post the exception. "Does not work on my
machine" is hard to reproduce or help out with.

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 14:00:56, Ajinkya Shukla (ajinkyashukl...@gmail.com)
wrote:

How can i make the following HTTPS request using akka-http to a jenkins
server?

curl -v -k --user "$USERNAME:$API_TOKEN" https://HOSTNAME.com/api/json

The curl produces the following HTTPS request:

Connected to HOST.com
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: Default Company Ltd
* Server auth using Basic with user 'USERNAME'
> GET /api/json HTTP/1.1
> Host: HOSTNAME
> Authorization: Basic API_TOKEN
> User-Agent: curl/7.43.0
> Accept: */*

However I am not able to make the above request using akka-http. I get a
SSL certificate error. Here is my code:


import javax.net.ssl.SSLContext

import akka.actor.{Actor, ActorLogging, ActorSystem}
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization,
BasicHttpCredentials}
import akka.http.scaladsl.{Http, HttpsConnectionContext}
import akka.stream.{ActorMaterializer, ActorMaterializerSettings,
Materializer}
import akka.util.ByteString
import com.typesafe.sslconfig.akka.AkkaSSLConfig
import com.typesafe.sslconfig.ssl.{SSLConfigSettings, SSLParametersConfig}

import scala.concurrent.Future

class Main extends Actor
  with ActorLogging {

  import akka.pattern.pipe
  import context.dispatcher

  implicit val system = ActorSystem("HelloSystem")

  final implicit val materializer: ActorMaterializer =
ActorMaterializer(ActorMaterializerSettings(context.system))

  val modernHttpsConnectionContext: HttpsConnectionContext = new
HttpsConnectionContext(
SSLContext.getDefault,
enabledProtocols = Some("TLSv1.2" :: "TLSv1.1" :: Nil)
  )

  class HttpClientSingleCustomHttps(connectionContext:
HttpsConnectionContext)
   (implicit val system: ActorSystem, val
mat: Materializer) {
def sendHttpReq(req: HttpRequest): Future[HttpResponse] =
  Http().singleRequest(req, connectionContext =
connectionContext).pipeTo(self)
  }

  override def preStart() = {
log.info("Making request")
val client = new
HttpClientSingleCustomHttps(modernHttpsConnectionContext)
val jenkinsRequest: HttpRequest = HttpRequest(
  uri = "https://HOSTNAME.com/api/json;,
  headers = List(
Authorization(BasicHttpCredentials("USERNAME","PASSWORD"))
  )
)
client.sendHttpReq(jenkinsRequest)
  }

  def receive = {
case HttpResponse(StatusCodes.OK, headers, entity, _) =>
  log.info("Got response, body: " +
entity.dataBytes.runFold(ByteString(""))(_ ++ _))
case HttpResponse(code, _, _, _) =>
  log.info("Request failed, response code: " + code)
  }

}

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

-- 
>>  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] Make HTTPS request using akka-http to jenkins server

2016-07-20 Thread Ajinkya Shukla
How can i make the following HTTPS request using akka-http to a jenkins 
server?

curl -v -k --user "$USERNAME:$API_TOKEN" https://HOSTNAME.com/api/json

The curl produces the following HTTPS request:

Connected to HOST.com
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: Default Company Ltd
* Server auth using Basic with user 'USERNAME'
> GET /api/json HTTP/1.1
> Host: HOSTNAME
> Authorization: Basic API_TOKEN
> User-Agent: curl/7.43.0
> Accept: */*

However I am not able to make the above request using akka-http. I get a 
SSL certificate error. Here is my code:


import javax.net.ssl.SSLContext

import akka.actor.{Actor, ActorLogging, ActorSystem}
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.{Authorization, 
BasicHttpCredentials}
import akka.http.scaladsl.{Http, HttpsConnectionContext}
import akka.stream.{ActorMaterializer, ActorMaterializerSettings, 
Materializer}
import akka.util.ByteString
import com.typesafe.sslconfig.akka.AkkaSSLConfig
import com.typesafe.sslconfig.ssl.{SSLConfigSettings, SSLParametersConfig}

import scala.concurrent.Future

class Main extends Actor
  with ActorLogging {

  import akka.pattern.pipe
  import context.dispatcher

  implicit val system = ActorSystem("HelloSystem")

  final implicit val materializer: ActorMaterializer = 
ActorMaterializer(ActorMaterializerSettings(context.system))

  val modernHttpsConnectionContext: HttpsConnectionContext = new 
HttpsConnectionContext(
SSLContext.getDefault,
enabledProtocols = Some("TLSv1.2" :: "TLSv1.1" :: Nil)
  )

  class HttpClientSingleCustomHttps(connectionContext: 
HttpsConnectionContext)
   (implicit val system: ActorSystem, val 
mat: Materializer) {
def sendHttpReq(req: HttpRequest): Future[HttpResponse] =
  Http().singleRequest(req, connectionContext = 
connectionContext).pipeTo(self)
  }

  override def preStart() = {
log.info("Making request")
val client = new 
HttpClientSingleCustomHttps(modernHttpsConnectionContext)
val jenkinsRequest: HttpRequest = HttpRequest(
  uri = "https://HOSTNAME.com/api/json;,
  headers = List(
Authorization(BasicHttpCredentials("USERNAME","PASSWORD"))
  )
)
client.sendHttpReq(jenkinsRequest)
  }

  def receive = {
case HttpResponse(StatusCodes.OK, headers, entity, _) =>
  log.info("Got response, body: " + 
entity.dataBytes.runFold(ByteString(""))(_ ++ _))
case HttpResponse(code, _, _, _) =>
  log.info("Request failed, response code: " + code)
  }

}

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