Re: [akka-user] get the public address of an actorsystem

936 views
Skip to first unread message

Patrik Nordwall

unread,
Nov 21, 2012, 9:53:18 AM11/21/12
to akka...@googlegroups.com
Hi John,

If you are using akka 2.1.0 RC2 you can grab that from
val myAddress = system.asInstanceOf[ExtendedActorSystem].provider.rootPath.address
  myAddress.host
  myAddress.port

If you prefer something nicer than the cast to ExtendedActorSystem you can place it in an extension.

/Patrik

On Wed, Nov 21, 2012 at 3:33 PM, John <john.d...@gmail.com> wrote:
Hello,

after creating an actorsystem with this config :
  remote {
    netty {
      hostname = ""
      port = 0
    }
  }

I am curious how I can tell what hostname and the port the actorsystem is actually bound to. Ok, the documentation tells me the hostname will actually be InetAddress.getLocalHost.getHostAddress, but that's not really what I want (and how about the port anyway?)

Thanks,

John

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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 post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
 
 



--
Patrik Nordwall
Typesafe - The software stack for applications that scale
Twitter: patriknw

√iktor Ҡlang

unread,
Nov 21, 2012, 10:15:24 AM11/21/12
to Akka User List
Also, a good question is what you need it for?

Cheers,
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

john doe

unread,
Nov 21, 2012, 10:19:36 AM11/21/12
to akka...@googlegroups.com
Well, suppose I have two applications trying to talk to eachother using akka remoting, how do I tell them the address of the other app?

2012/11/21 √iktor Ҡlang <viktor...@gmail.com>

Patrik Nordwall

unread,
Nov 21, 2012, 10:22:52 AM11/21/12
to akka...@googlegroups.com
Yes, that's a very good question Viktor.
John, normally you don't. You send a message to the other system. It grabs the sender ActorRef, and can send messages back. No need to pass addresses explicitly.
/Patrik

Twitter: @patriknw


john doe

unread,
Nov 21, 2012, 10:25:07 AM11/21/12
to akka...@googlegroups.com
Sure, but how do you bootstrap this? in your example the first actorsystem knows the address of the other right?

2012/11/21 Patrik Nordwall <patrik....@gmail.com>

Patrik Nordwall

unread,
Nov 21, 2012, 10:34:44 AM11/21/12
to akka...@googlegroups.com
On Wed, Nov 21, 2012 at 4:25 PM, john doe <john.d...@gmail.com> wrote:
Sure, but how do you bootstrap this? in your example the first actorsystem knows the address of the other right?

yes, but that is not solved by grabbing your own address.
It's solved by configuration or by using Akka Cluster (experimental in 2.1.0-RC2)

Patrik Nordwall

unread,
Nov 21, 2012, 10:46:28 AM11/21/12
to akka...@googlegroups.com

On Wed, Nov 21, 2012 at 4:44 PM, John <john.d...@gmail.com> wrote:
Yes, it can also be solved using zookeeper, but for that I need the host:port of each app that will register itself, hence my original question

ok, that answers Viktor's question as well. Happy hAkking!
 

thanks!

Patrik Nordwall

unread,
Nov 23, 2012, 11:16:16 AM11/23/12
to akka...@googlegroups.com
John, an important heads-up. In upcoming version 2.1.0-RC3 you will have to change to
val myAddress = system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress

/Patrik
Reply all
Reply to author
Forward
0 new messages