librespot-org / librespot-java

The most up-to-date open source Spotify client
Apache License 2.0
373 stars 91 forks source link

Can't run librespot-java in a VM #479

Open iVolt1 opened 2 years ago

iVolt1 commented 2 years ago

I will first say that librespot-java works flawlessly for spotify audio and metadata and I appreciate the effort put into the project.

I previously reported this issue at https://github.com/spocon/spocon/issues/46 .

I am running spocon in a virtualbox VM. Initially it took me a day or two to figure out why spotify could not see librespot-java.

It looks like this code excludes running VMs, possibly for no apparent reason. I changed the x08 to x06the MAC in the VM settings and now spotify connects to spocon.

Can this code be removed or modified so that librespot-java works out of the box in a VM? At the very least could a warning/workaround be put into the readme install instructions?

https://github.com/librespot-org/librespot-java/blob/dev/lib/src/main/java/xyz/gianlu/librespot/ZeroconfServer.java

... public class ZeroconfServer implements Closeable { public static final String SERVICE = "spotify-connect"; private final static int MAX_PORT = 65536; private final static int MIN_PORT = 1024; private static final Logger LOGGER = LoggerFactory.getLogger(ZeroconfServer.class); private static final byte[] EOL = new byte[]{'\r', '\n'}; private static final JsonObject DEFAULT_GET_INFO_FIELDS = new JsonObject(); private static final JsonObject DEFAULT_SUCCESSFUL_ADD_USER = new JsonObject(); private static final byte[][] VIRTUAL_INTERFACES = new byte[][]{ new byte[]{(byte) 0x00, (byte) 0x0F, (byte) 0x4B}, // Virtual Iron Software, Inc. new byte[]{(byte) 0x00, (byte) 0x13, (byte) 0x07}, // Paravirtual Corporation new byte[]{(byte) 0x00, (byte) 0x13, (byte) 0xBE}, // Virtual Conexions new byte[]{(byte) 0x00, (byte) 0x21, (byte) 0xF6}, // Virtual Iron Software new byte[]{(byte) 0x00, (byte) 0x24, (byte) 0x0B}, // Virtual Computer Inc. new byte[]{(byte) 0x00, (byte) 0xA0, (byte) 0xB1}, // First Virtual Corporation new byte[]{(byte) 0x00, (byte) 0xE0, (byte) 0xC8}, // Virtual access, ltd. new byte[]{(byte) 0x54, (byte) 0x52, (byte) 0x00}, // Linux kernel virtual machine (kvm) new byte[]{(byte) 0x00, (byte) 0x21, (byte) 0xF6}, // Oracle Corporation new byte[]{(byte) 0x18, (byte) 0x92, (byte) 0x2C}, // Virtual Instruments new byte[]{(byte) 0x3C, (byte) 0xF3, (byte) 0x92}, // VirtualTek. Co. Ltd. new byte[]{(byte) 0x00, (byte) 0x05, (byte) 0x69}, // VMWare 1 new byte[]{(byte) 0x00, (byte) 0x0C, (byte) 0x29}, // VMWare 2 new byte[]{(byte) 0x00, (byte) 0x50, (byte) 0x56}, // VMWare 3 new byte[]{(byte) 0x00, (byte) 0x1C, (byte) 0x42}, // Parallels new byte[]{(byte) 0x00, (byte) 0x03, (byte) 0xFF}, // Microsoft Virtual PC new byte[]{(byte) 0x00, (byte) 0x16, (byte) 0x3E}, // Red Hat Xen, Oracle VM, Xen Source, Novell Xen new byte[]{(byte) 0x08, (byte) 0x00, (byte) 0x27}, // VirtualBox new byte[]{(byte) 0x00, (byte) 0x15, (byte) 0x5D}, // Hyper-V }; ...

Thanks,

iVolt

jpgrovy commented 2 years ago

Hello,

Are you still able to capture metadata, etc as of yesterday?

iVolt1 commented 2 years ago

I haven't updated or changed anything in quite a while, but librespot-java is working and sending metadata.

jpgrovy commented 2 years ago

I use this project that is built on librespot-java and it appears to have went down.

https://github.com/entriphy/sp-playcount-librespot

I wasn’t sure if it’s the librespot project that broke it. I tried deploying my own instance and something also is working. I’m trying to figure out where the issue lies 😔

Sent from my iPhone

On Apr 22, 2022, at 8:58 AM, iVolt1 @.***> wrote:

 I haven't updated or changed anything in quite a while, but librespot-java is working and sending metadata.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

iVolt1 commented 5 months ago

Hi devgianlu,

This issue still exists even in the latest releases of librespot-java. I have gotten stuck in a troubleshooting loop a few times when after many months I have had to move my librespot-java/owntone environment to a different vm and the librespot-java server device doesn't appear in spotify. I eventually remember that the code excludes those mac addresses and have to go into the vm settings and fake the mac address.

Is there a reason to exclude librespot-java from running in a vm such as a spotify licensing issue? librespot-java runs runs great for me in hyper-v and VirtualBox so it would be nice if that code could be removed in the future.

I currently run the librespot-java/owntone environment in the HomePod Connect addon on Home Assistant and works Home Assistant dashboard which is probably the best whole house audio arrangement anywhere, even in a vm.

It looks like this code excludes running VMs, possibly for no apparent reason. I changed the x08 to x06the MAC in the VM settings and now spotify connects to spocon.

Thanks for the great project,

ivolt1

@jpgrovy I think you posted in the wrong thread, but your project looks promising.

iVolt1 commented 5 months ago

I think this issue reported by @dolanjp was also a vm exclusion issue:

https://github.com/librespot-org/librespot-java/issues/716