You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派Raspbian系统Chromium中Spotify Web Player报WebSocket错误求助

Troubleshooting WebSocket Errors with Spotify Player on Raspberry Pi Chromium

Hey there, let's break down why your Spotify web player works smoothly on Mac Chrome but throws WebSocket errors on Raspberry Pi's Chromium. I'll walk you through the most common culprits and actionable fixes to get your player up and running.


1. First, Check Your Chromium Version

Spotify's Web Playback SDK relies on modern browser features, and older Chromium builds on Raspbian might lack full WebSocket or API compatibility:

  • To check your version: Open Chromium, type chrome://version in the address bar, and note the version number (Spotify requires at least Chrome/Chromium 72+).
  • If it's outdated, update it via the terminal:
    sudo apt update && sudo apt full-upgrade
    
    Reboot your Pi and launch Chromium again after the update finishes.

2. Verify Network & WebSocket Access

Raspberry Pi's network settings or your router might be blocking Spotify's WebSocket endpoints:

  • Test the WebSocket connection directly: Open Chromium's DevTools (F12), go to the Network tab, filter by WS, then visit wss://ws.spotify.com. If the connection fails, you likely have a network restriction.
  • Check local firewall rules: If you're using ufw on your Pi, ensure outbound WebSocket traffic (port 443, since Spotify uses wss over HTTPS) is allowed. Run sudo ufw allow out 443/tcp if needed.
  • Double-check your router settings: Some routers block WebSocket connections by default—look for "WebSocket" or "WSS" in your router's firewall settings and enable it.

3. Audit Your Spotify SDK Initialization Code

Small differences in browser behavior can break initialization on ARM-based Chromium:

  • Ensure audio permissions are granted: Spotify's player requires access to your audio device. Add this check before initializing the SDK:
    navigator.mediaDevices.getUserMedia({ audio: true })
      .then(() => {
        // Proceed with Spotify SDK initialization here
      })
      .catch(err => console.error("Failed to get audio permission:", err));
    
  • Validate your hardcoded track URI: Make sure the track you're trying to play is accessible with your Spotify account (e.g., it's not a private playlist track or region-locked). Test the URI directly in the Spotify web player first to confirm.

4. Dig Into DevTools Error Details

The exact WebSocket error message will tell you exactly what's wrong:

  • Open Chromium's DevTools (F12) and go to the Console tab. Look for errors starting with WebSocket connection to 'wss://ws.spotify.com/...' failed.
    • Error code 1006: Connection closed unexpectedly—usually a network or server-side issue (check your internet connection or router).
    • Error code 1008: Policy violation—might be due to missing permissions or blocked endpoints.
    • Authentication errors: If you see invalid token or similar, double-check your Spotify API credentials and token refresh logic.

5. Rule Out Remote Desktop Audio Issues

If you're using VNC or Chrome Remote Desktop to access your Pi, Chromium might not detect the audio device properly, which can break the WebSocket connection for Spotify's player:

  • Try using the Pi's local screen and keyboard directly to test the player.
  • If remote access is necessary, ensure your remote desktop tool is configured to pass through audio to the Pi's device.

Start with checking your Chromium version and grabbing the full error message from DevTools—those two steps will narrow down the problem faster than anything else. Let me know what you find!

内容的提问来源于stack exchange,提问作者Frostbch

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:38:27