owntone / owntone-server

Linux/FreeBSD DAAP (iTunes) and MPD audio server with support for AirPlay 1 and 2 speakers (multiroom), Apple Remote (and compatibles), Chromecast, Spotify and internet radio.
https://owntone.github.io/owntone-server
GNU General Public License v2.0
2.05k stars 235 forks source link

Built on macOS, websocket doesn't work #1699

Open kajarit opened 9 months ago

kajarit commented 9 months ago

I've built OwnTone server on macOS 11.7.10 Big Sur with the help of these sources:

OwnTone Server Version 28.8

Almost everything works fine, except things I noticed:

  1. Now playing page doesn't refresh on track change, so when one track ends and the next starts, it still displays the previous track
  2. Selecting a new output (AirPlay speaker) also isn't reflected, just after page reload
  3. When I start a library update, then the About page also won't update until I reload it
  4. When I connect to the websockets endpoint, it doesn't sends any updates, but connection is ok

I also noticed, that the browser page also updates itself when I move to other tab and back.

Postman test

OwnTone websocket Postman

Postman header (defaults hidden)

OwnTone websocket Postman header

And here's the owntone.log fitered for web debug messages:

[2023-12-20 16:57:06] [DEBUG]      web: notify callback request: { "notify": [ "player" ] }
[2023-12-20 16:57:06] [DEBUG]      web: notify callback request: { "notify": [ "player" ] }
[2023-12-20 16:57:06] [DEBUG]      web: notify callback event received: player
[2023-12-20 16:57:06] [DEBUG]      web: notify callback event received: player
[2023-12-20 16:57:28] [DEBUG]      web: notify callback reason: 71
[2023-12-20 16:57:28] [DEBUG]      web: notify callback reason: 71
[2023-12-20 16:57:28] [DEBUG]      web: notify callback reason: 71
[2023-12-20 16:57:28] [DEBUG]      web: notify callback reason: 71
[2023-12-20 16:57:31] [DEBUG]      web: notify callback reason: 11
[2023-12-20 16:57:31] [DEBUG]      web: notify callback reason: 11
ejurgensen commented 9 months ago

Thanks for reporting and for good info about the issue. @hacketiwack do you think you can look into this? Maybe PR #1446 is of relevance here.

kajarit commented 9 months ago

Thanks for looking into this, what about Postman not receiving any notifications, but still connected during playback?

ejurgensen commented 8 months ago

@hacketiwack any chance you can look at this?

hacketiwack commented 8 months ago

Yes, sure. Let me check that.

hacketiwack commented 8 months ago

@kajarit do you have any particular reason to build on an unsupported version of macOS (Big Sur is unsupported since September 2023) and use macports instead of homebrew? No judgment here, I just don't want to waste my time building a virtual machine in a specific version when there is no particular reason.

kajarit commented 8 months ago

I have a 2014 Mac Mini, and I use homebrew. I don't plan to change this machine in the near future.

hacketiwack commented 8 months ago

@kajarit, I built OwnTone on a macOS Big Sur virtual machine (following the instructions I gave earlier last year). I could reproduce the errors and the behaviour. However, I don't know what they really mean. I guess error codes are related to these reasons. @ejurgensen, do you have any idea what these codes mean? In the logs there are plenty of notify callback reasons, like: 11, 71, 49, 20, 53, 0, 6, 38, 78. The only other suspicious error is: mdns: Error registering record owntone.local, error -65540 but it probably has nothing to do with our problem here.

I also tested with macOS Monterey with the same results. I suspect that even with the latest version of macOS, you'll have the same problems.

In your specific situation @kajarit macOS Big Sur is not supported and Homebrew is also not supported on this version of macOS. Therefore, my recommendations would be to make use of the containerisation to avoid having to built OwnTone by yourself.

And if you can't install Docker properly. I would suggest to upgrade your Mac Mini to a newer version of macOS with the help of Dortania

kajarit commented 8 months ago

Thanks for the tips, I'll have a look on those. Before building natively, I also tried with Docker but I couldn't make it work for several reasons.

ejurgensen commented 8 months ago

I don't know those error codes. I think if this issue isn't present with current versions of MacOS/libwebsockets then it's fine to close the issue.

kajarit commented 8 months ago

I also tested with macOS Monterey with the same results. I suspect that even with the latest version of macOS, you'll have the same problems.

Does this mean that even with the latest macOS the websocket doesn't work?

hacketiwack commented 8 months ago

Does this mean that even with the latest macOS the websocket doesn't work?

I need to test it with Sonoma to be sure.

hacketiwack commented 8 months ago

OK. No good news is coming with this comment. Actually, I get the error on all versions of macOS: from Big Sur to Sonoma.

Now the question is where to start searching within the integration of libwebsocket. @ejurgensen any idea where I could start my investigation? What I could try is to compile libwebsockets myself and not take the one coming from Homebrew.

ejurgensen commented 8 months ago

Actually, I get the error on all versions of macOS: from Big Sur to Sonoma.

So you get an error message - what is that? From the thread above I couldn't see an error message (the notify reasons aren't errors, and the mdns error is unrelated).

If you have some error message I suppose you could search for it in the lws source code. But yes, compiling lws yourself with debug symbols could also be useful for debugging. Have you found a basic way to reproduce? Just browsing the web UI might be a difficult way, since there is a bunch of communication going on, so if you can isolate the error it would be useful.

hacketiwack commented 8 months ago

You're right these are not error messages, but "reasons" for whatever it means. I don't have receive any errors or whatever.

I will try to compile with debug symbols and try to find a scenario that could provoke these messages in a reliable way.

kajarit commented 8 months ago

Do we know what was the last known working websocket version of OwnTone/macOS ever?

hacketiwack commented 8 months ago

Do we know what was the last known working websocket version of OwnTone/macOS ever?

Excellent question. No idea.

kajarit commented 7 months ago

What I could try is to compile libwebsockets myself and not take the one coming from Homebrew.

Hi @hacketiwack, have you been able to try this?

hacketiwack commented 7 months ago

@kajarit i did compile my own version of libwebsocket but it gives the same results. I’m quite puzzled about the reason of this not working properly.

kajarit commented 6 months ago

@hacketiwack should we raise an issue at libwebsockets?

hacketiwack commented 6 months ago

Actually, yes, that would be great. I was wondering if there was some kind of HTML test with libwebsockers server application that could be used to test on macOS.

kajarit commented 6 months ago

I am not sure how to create an issue that would help explain the problem.

ejurgensen commented 6 months ago

I am planning to write a test program to help debug this. So basically copy websocket.c into a standalone server. I hope that will also help me understand the current implementation. It's a bit of a black box to me now, even after trying to read the code.

hacketiwack commented 6 months ago

@ejurgensen That would be great to have such test program to debug. Thanks.