Join 3,433 readers in helping fund MetaFilter (Hide)


Forcing Nicecast to Port 8000?
June 20, 2014 7:19 AM   Subscribe

The Community Radio Station I helped found uses Nicecast to repeat the signal from the station to our streaming provider. The problem is that if there is a power outage when the system starts back up Nicecast thinks Port 8000 is busy and so switches to Port 8001.

I contacted Rogue Amoeba about this, and it was as if they didn't read my question. They said:

"When you start Nicecast up, the Built-In Server will detect if the port you're set to broadcast on is in use by another application. To avoid conflicts with other streaming software, it will increment its port as needed. This can happen other software is making use of that port which Nicecast is assigned to use. We've also seen this happen if you quit and re-launch Nicecast very quickly, before its server process has a chance to clean up and free the port for use again."

Well, I know this is happening, but it isn't because another application is using the port. It is Nicecast. When I replied to Rogue Amoeba to let them know this and asked if there was a way to force Nicecast to only use Port 8000 I never heard back.

During the summers here in Vermont we get occasional thunderstorms, and because all of our power lines are above ground — and we have lots of trees — we occasionally lose power. Our station is designed to return to a normal state and play music in case this happens, but since Nicecast doesn't go to Port 8000 it means I get phone calls, emails, etc telling me there is dead air, and I have to screen share in to the system and change the port manually.

Any ideas on how I can make Nicecast only use Port 8000?
posted by terrapin to Computers & Internet (9 answers total)
 
There are a couple suggestions here. I'm also curious what might be going on with the machine that's running Nicecast; is it hooked to a UPS that is sending it a shutdown signal when the power goes away and then starting it back up again when it resumes? Maybe that's causing the rapid stop/start situation described in Rogue Amoeba's response. If that's the case, you might get better reliability by tweaking the settings on the UPS so it waits longer before shutting down the computer, or by just disconnecting its communication from that machine altogether.

I know community radio stations are not known for having lots of funding laying around, but maybe consider a generator/UPS to keep the juice flowing and the station on the air during such outages.
posted by contraption at 7:31 AM on June 20


You are correct that the system is plugged into a UPS. One that only has about an hour of juice. I will pass on the link you included as it above me. I am afraid to put the system off of the UPS for fear of frying the most expensive piece of hardware our little (poor) station owns.

A generator is on our wishlist, and may be the next thing we fund raise for after we raise enough money for our transmitter/antenna ($10k!). One of the reasons our little station formed was that after Tropical Storm Irene hit us all the power was out, roads were washed away and we had trouble getting local information in a timely manner. So we want a generator so we can help spread information in case of another emergency.

Thanks.
posted by terrapin at 7:43 AM on June 20


With the understanding that I don't know what I'm talking about, it seems to me that the practical question here is "how do I make the system clear Port 8000 on bootup"?

Or, if the problem really is one of starting up Nicecast too quickly after it goes down, can you have the system wait a minute or three before starting it up again?
posted by Shmuel510 at 7:55 AM on June 20


...and now that I've actually looked at contraption's link, I see you're way ahead of me. Never mind then...
posted by Shmuel510 at 7:57 AM on June 20


When you start up Nicecast, you could instead have a script that 1) checks for anything listening/streaming on port 8000, 2) if so, kills it, and 3) starts Nicecast.

Items 1) and 2), from contraption's list, would be, as a bash command:

lsof -i TCP:8000 | awk '{print $2}' | xargs kill -9

and then 3):

open -a /Applications/Nicecast.app

You could put these two together in a single shell script:

#!/bin/sh
lsof -i TCP:8000 | awk '{print $2}' | xargs kill -9
open -a /Applications/Nicecast.app

and then have this script run upon login. You can test this script by running it when Nicecast is already open, to simulate port 8000 already being used by Nicecast. You might also have to build in a loop with a delay, just in case it takes the Nicecast daemon a little bit of time to be killed, so that when Nicecast is already launched, it doesn't see the daemon-in-process-of-dying and assign itself to port 8000.
posted by suedehead at 8:25 AM on June 20


You are correct that the system is plugged into a UPS. One that only has about an hour of juice. I will pass on the link you included as it above me. I am afraid to put the system off of the UPS for fear of frying the most expensive piece of hardware our little (poor) station owns.

My suggestion wasn't that the computer's power connection be detached from the UPS, but rather that you try unhooking the communication cable (probably USB or ethernet) that allows the UPS to tell the computer when power has been lost. My suspicion here is that when there is a momentary outage (as when a tree falls across a line and the utility grid takes a moment to automatically re-route power along another path) the UPS might be saying "Power outage! Shut it all down! Oh wait never mind it's back again!" causing the kind of rapid stop-start situation described by Rogue Amoeba. You could do a quick test to see if this is the case: try pulling the plug on the UPS a few times for varying lengths of time, both with the UPS communication cable attached and with it detached. If you can repeatably make the problem occur with the comm cable connected but it goes away when it's disconnected, you know the issue is with the UPS.

From there, it's just a matter of figuring a way to change the behavior of the UPS. The simplest thing to do would be just to leave it disconnected and make sure you have somebody onsite to shut the Mac down manually if the power goes out for an extended period. Depending on the specifics of the UPS it might also be possible to configure it to wait longer before the sending shutdown signal.

suedehead's script is a good way to automatically deal with the fallout of a failed shutdown of Nicecast, but obviously the preferable thing would be to not have it fail in the first place.
posted by contraption at 10:16 AM on June 20


I'm a little confused: if the Nicecast machine is restarting from a shut-down state, how is it possible that something else is running on that port? Are you sure you're not trying to start Nicecast twice?
posted by rhizome at 10:36 AM on June 20


Thanks suedehead, and others. My colleague wrote an script that will run on start up, which we hope to test soon. Will report back.
posted by terrapin at 2:07 PM on June 20


Tried all of the above, which helped give us ideas, but were unsuccessful on our own. The two things we did were 1) we posted a job on Metafilter, and someone wrote a script that seems to be working; and 2) Nicecast software developers communicated with us and gave us a test version of the software to see if it helped. So far, so good.

Thanks all.
posted by terrapin at 3:23 PM on July 20


« Older I get conflicted information a...   |  There are loads of options (to... Newer »

You are not logged in, either login or create an account to post comments