spotify-web-helper icon indicating copy to clipboard operation
spotify-web-helper copied to clipboard

Get listening port directly

Open atatdotdot opened this issue 6 years ago • 5 comments

Just discovered this project; great work!

Was just looking at how you find the port and thought you could get it directly by looking at listening ports by process ID, rather than by sequential scan, e.g.:

netstat -lptn 2>/dev/null |sed -n -e 's/^.*127.0.0.1:\([[:digit:]]\+\)\s.*spotify.*$/\1/p'

I've tested this on Linux; I would have thought it would work unmodified on MacOS, but might need some work on Windows.

atatdotdot avatar Jun 18 '18 15:06 atatdotdot

Hi atatadot!

Thank you! This sounds like great potential to optimize. For me it does not seem to work on macOS. The command does not fail, but the output is empty.

JonnyBurger avatar Jun 18 '18 15:06 JonnyBurger

The issue is either with netstat or with sed. I believe sed is a bit variable between between systems. Can you paste the whole output of netstat -lptn and I'll have a look? With spotify web helper running, obviously!

atatdotdot avatar Jun 18 '18 16:06 atatdotdot

Sure, we can remote debug this.

This is what I see: image

JonnyBurger avatar Jun 19 '18 08:06 JonnyBurger

Try this instead; should work on both Linux and Mac OS:

lsof -iTCP@localhost -sTCP:LISTEN |sed -n -e 's/^spotify.*localhost:\([[:digit:]]\+\)\s.*$/\1/p'

atatdotdot avatar Jun 19 '18 11:06 atatdotdot

Unfortunately not..

image

JonnyBurger avatar Jun 20 '18 07:06 JonnyBurger