opencast / opencast

The free and open source solution for automated video capture and distribution at scale.
https://opencast.org
Educational Community License v2.0
394 stars 234 forks source link

`check_port` ignores the bind address #2436

Open JulianKniephoff opened 3 years ago

JulianKniephoff commented 3 years ago

When you start Opencast, the start scripts (specifically check_port) first check whether the HTTP and HTTPS ports configured in etc/org.ops4j.pax.web.cfg are already in use. They do this by looking for any open connection with the appropriate port number, but don't look at the address bound in that connection. It should compare this to the address(-es) configured in the same file (after potentially resolving hostnames ...).

This is problematic for example in the following situation: I'm running a certain web service locally for my own personal use. "Naturally" it listens on 8080. Being an Opencast dev, I of course already foresee conflict, and I could just change that port, but I always have trouble coming up with random port numbers, plus they might just collide with something else. 8080 (or http-alt in IANA lingo) is the correct port for this service, as it is for Opencast. But luckily I can also just bind that service to an alternative loopback IP; in my case (for no particular reason) 127.0.2.1.

While admittedly a bit esoteric, this works: You have the entire address space of 127.0.0.0/8 as loopback addresses at your disposal, and each of those can accept connections on the same port at the same time. And considering that there is actually some semantic meaning to a lot of port numbers, this seems to me to be a more reliable way to disambiguate situations like this. :thinking:

Anyway, Opencast doesn't support this use case currently. :sweat_smile: I wanted to change that, but it turned out to be harder than I thought, so for now this issue will have to suffice.

gregorydlogan commented 3 years ago

I wonder if this is why I'm seeing conflicts with Chrome of all things... Lately I've noticed that when starting Opencast it will sometimes say that 8080 is already in use, and will continue to do so until Chrome is closed. Hrm...

JulianKniephoff commented 3 years ago

Huh, that's weird. Haven't seen that. :thinking: Maybe an extension is running something on 8080 somewhere?

gregorydlogan commented 3 years ago

Probably, 8080 is too common a dev port for this to be missed by everyone else on the planet :)