ipv4 and ipv6 socket binding?

39 views
Skip to first unread message

gro...@gmail.com

unread,
Jul 4, 2017, 10:52:50 PM7/4/17
to finatra-users
Hi

I'm a new Finatra user. I'm seeing something strange and perhaps somebody can help me figure out what is going on.

Java, not Scala unfortunately.

I've got a MyServer that inherits from AbstractHttpServer. It runs just fine, but it seems that it binds on either ipv4 or ipv6, while the AdminServer is able to listen on both. I'm not sure why.

If I use listenAddress="127.0.0.1:9090" then it seems I get ipv4 only.
WORKS: curl -v http://127.0.0.1:9090/ -4
FAILS: curl -v http://127.0.0.1:9090/ -6 (Fails because obviously that isnt ipv6 address)
WORKS: curl -v http://localhost:9090/ -4
FAILS: curl -v http://localhost:9090/ -6

That last one is the strange one to me. I get 'Connection refused'. However, I can hit the AdminServer fine on both.

WORKS: curl -v http://localhost:9990/admin -6
WORKS: curl -v http://localhost:9990/admin -4

Am I missing something? Ideally, I would like MyServer to bind the same way that AdminServer does. Is this possible in Finatra?

Thanks
Greg

Isabel Martin

unread,
Jul 7, 2017, 8:01:26 PM7/7/17
to gro...@gmail.com, finatra-users
Hi Greg,

Do you mind sharing some more information about your configuration? I noticed that you're not using the default finatra http port, which is :8888. I was able to connect just using the finatra hello-world example.

Thanks,
Isabel


--
You received this message because you are subscribed to the Google Groups "finatra-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to finatra-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Greg Roodt

unread,
Jul 8, 2017, 7:55:23 AM7/8/17
to Isabel Martin, finatra-users
Sure, no problem.

I've created a repo here that reproduces the error for me: https://github.com/groodt/finatra-tcp46
See if you see the same thing.

OSX: 10.12.4
Java: 1.8.0_112

Perhaps I'm doing this wrong. Now that I think about it, it seems a bit pointless specifying a host in the listenAddress anyway? Perhaps that is what throws things off? I'm surprised that admin works fine though, although, also thinking about it, admin starts another server and probably just reads the port integer and not the host, so it binds differently. I've not dug into the finatra/finagle code enough yet.

It's weird though, both admin server and this custom server both show tcp46 listening in netstat.



Isabel Martin

unread,
Jul 12, 2017, 1:27:54 PM7/12/17
to Greg Roodt, finatra-users
Hi Greg,

I looked at your code, and you don't need to specify "localhost" when you override the default HTTP port. I'm honestly not sure why that makes a difference for ipv4 vs ipv6 but when I ran your server after changing "localhost:9090" to just ":9090" everything seemed fine to me. Sorry for the unsatisfying answer, but this should probably fix your issue.

Thanks,
Isabel
Reply all
Reply to author
Forward
0 new messages