pianobar icon indicating copy to clipboard operation
pianobar copied to clipboard

Getting 403 errors when using proxy

Open takeda opened this issue 3 years ago • 10 comments

Subject of the issue

So either Pandora changed something recently or using proxy produces a lot of 403 errors. I'm starting to think that most likely it is the later and pianobar uses proxy for some requests while others go without the proxy.

Here's example of output:

 ~  ALL_PROXY=socks5h://127.0.0.1:1080 pianobar
Welcome to pianobar (2020.11.28)! Press ? for a list of commands.
[?] Email: <snip>
[?] Password:
(i) Login... Ok.
(i) Get stations... Ok.
|>  Station "Me likes (mix of everything)" (<snip>)
(i) Receiving new playlist... Ok.
|>  "Hocus Pocus" by "Focus (Prog)" on "Then: Totally Oldies, Vol. 6"
/!\ Unable to open audio file (Server returned 403 Forbidden (access denied))
|>  "Killer Queen (Remastered 2011)" by "Queen" on "The Platinum Collection (Greatest Hits I II & III - 2011 Remaster)"
/!\ Unable to open audio file (Server returned 403 Forbidden (access denied))
|>  "Of a Lifetime" by "Journey" on "Journey"
/!\ Unable to open audio file (Server returned 403 Forbidden (access denied))
|>  "While My Guitar Gently Weeps (Remastered 2009)" by "The Beatles" on "The Beatles (Remastered)"
(i) Receiving new playlist... Ok.
|>  "Fern" by "Zoë Keating" on "One Cello X 16: Natoma"
|>  "Miss You" by "Trentemøller" on "The Last Resort"
/!\ Unable to open audio file (Server returned 403 Forbidden (access denied))
|>  "Voyager" by "Daft Punk" on "Discovery"
/!\ Unable to open audio file (Server returned 403 Forbidden (access denied))
|>  "The Scientist" by "Coldplay" on "A Rush Of Blood To The Head" <3
/!\ Unable to open audio file (Server returned 403 Forbidden (access denied))
(i) Receiving new playlist... Ok.
|>  "Knockin' On Heaven's Door" by "Guns N' Roses" on "Use Your Illusion II" <3
|>  "No More Tears (Edit)" by "Ozzy Osbourne" on "Memoirs of a Madman" <3
#   -05:20/05:56

This doesn't only happen at start, but during playback it also will have some songs that it will skip due to 403 error.

Your environment

  • version of pianobar 2020.11.28
  • your Linux distribution and release version: OS X, pianobar installed through Nix
  • ffmpeg/libav version and the flags it was compiled with (if you compiled yourself)

libao:

    "env": {
      "__darwinAllowLocalNetworking": "",
      "__impureHostDeps": "/bin/sh /usr/lib/libSystem.B.dylib /usr/lib/system/libunc.dylib /dev/zero /dev/random /dev/urandom /bin/sh",
      "__propagatedImpureHostDeps": "",
      "__propagatedSandboxProfile": "",
      "__sandboxProfile": "",
      "buildInputs": "/nix/store/559qk5ycrc6zcxzwxfjv84gjyb94383k-apple-framework-CoreAudio /nix/store/rmw665p9ka21la6pqnyjncyf4z4in58d-apple-framework-CoreServices /nix/store/781yy6vfk84fjxa71ddn7nlcsklh7wvs-apple-framework-AudioUnit",
      "builder": "/nix/store/xxfxh4npdlp0w5winp2f17ji1yxdivn3-bash-4.4-p23/bin/bash",
      "configureFlags": "--disable-broken-oss --enable-alsa-mmap",
      "depsBuildBuild": "",
      "depsBuildBuildPropagated": "",
      "depsBuildTarget": "",
      "depsBuildTargetPropagated": "",
      "depsHostHost": "",
      "depsHostHostPropagated": "",
      "depsTargetTarget": "",
      "depsTargetTargetPropagated": "",
      "dev": "/nix/store/vwf5632gp5lrsqmp2sqnz76ayfw9mj2m-libao-1.2.2-dev",
      "doCheck": "",
      "doInstallCheck": "",
      "doc": "/nix/store/c5spzhvginb2bwp59xfi6r42k8wp65mq-libao-1.2.2-doc",
      "man": "/nix/store/glxaqj57vrlw25xvhpa48bgy7l6ihlb0-libao-1.2.2-man",
      "name": "libao-1.2.2",
      "nativeBuildInputs": "/nix/store/r3a46cxbcwk3hmpi44rb8pfbwrwymfzx-hook /nix/store/ycp37qg19f9igkis6h7ccm83svg5jwaw-pkg-config-wrapper-0.29.2",
      "out": "/nix/store/j7q2ckz7zmi7h8vhpn207dikwbj3ivaf-libao-1.2.2",
      "outputs": "out dev man doc",
      "patches": "",
      "pname": "libao",
      "propagatedBuildInputs": "",
      "propagatedNativeBuildInputs": "",
      "src": "/nix/store/pmfl5jvh9g8wxkcpyai1sdmmr3syf46z-source",
      "stdenv": "/nix/store/b9h2w4nd3rg3hi9yga9ycpgppb5hl2p2-stdenv-darwin",
      "strictDeps": "",
      "system": "x86_64-darwin",
      "version": "1.2.2"
    }

ffmpeg:

    "env": {
      "__darwinAllowLocalNetworking": "",
      "__impureHostDeps": "/bin/sh /usr/lib/libSystem.B.dylib /usr/lib/system/libunc.dylib /dev/zero /dev/random /dev/urandom /bin/sh",
      "__propagatedImpureHostDeps": "",
      "__propagatedSandboxProfile": "",
      "__sandboxProfile": "",
      "bin": "/nix/store/d92mnlm89qf0j9jmp98a4c4c8x4ggcc0-ffmpeg-4.4-bin",
      "buildInputs": "/nix/store/76l3s32qvy7zsa4smw0sd4g43632xp6r-bzip2-1.0.6.0.2-dev /nix/store/9jwcwx8ff9l7hmbqvddvzkj9fyyhifyd-fontconfig-2.13.92-dev /nix/store/smv0pr1rzyyds02q87qsw217xn8i8l8w-freetype-2.10.4-dev /nix/store/4y639v5mqfjxbj4l0xj66cwkwzh2vf1z-gnutls-3.7.1-dev /nix/store/3833z5d0n3b57fhyiswa9zqjfig0v1mn-libiconv-50 /nix/store/jmv5ilvhs8pr9m4fwj57la8bvypp545r-lame-3.100 /nix/store/lghm9ilk24l0xh39j4mxr01r1r8j40f1-libass-0.15.1 /nix/store/prx18pkg8r9vn42g6148dd6vgcjnbdbz-libogg-1.3.4-dev /nix/store/grlaz2yp6wrrsvyhq5b8dh5k7qr5r37d-libssh-0.8.9 /nix/store/gq8xm63giaflc1zkzv87y7ysjscz8r7i-libtheora-1.1.1-dev /nix/store/aykcz4ympnprqkmn0bbgbz296xwpl6id-libvorbis-1.3.7-dev /nix/store/47wzkba0h7sdclfmqjkxd8wq69gnsgx9-xz-5.2.5-dev /nix/store/ilijfc2bixm1byij45x24xrvha0l70vm-soxr-0.1.3 /nix/store/m5zqwjygg3zm7cira58n85005w4g6d05-x264-20191217-2245-dev /nix/store/n5xf1ccqqlqz0p241zqlc6s12m6ybc7r-x265-3.4 /nix/store/i8h25vl9vg69bl04qw0vz44kxdw85192-xvidcore-1.3.5 /nix/store/9zr9qrld6sy6v0ajck4zxhw2l8716yza-zlib-1.2.11-dev /nix/store/dpb85ip45lnbj85kxq8fgcmnj536d23k-libopus-1.3.1-dev /nix/store/jmkijnlw5a95p5k3wk294jw6kncxlw9m-speex-1.2.0-dev /nix/store/j8w94qy2ynaz7xmgs5pc50gfnv29mmwc-nv-codec-headers-9.1.23.1 /nix/store/lpskcijyj70d51sifxiss9imhzs8gqhl-libvpx-1.10.0-dev /nix/store/znl8p7224vs1lh6kcq69wpb0jdn5y0xz-apple-framework-Cocoa /nix/store/pf7c3gidz1sdi8w0g0nqahcy4d6pnhcs-apple-framework-CoreMedia /nix/store/h1p2gzrff1r66k26fg3gnylnxjnjarmp-apple-framework-VideoToolbox /nix/store/b8l0xclgbl70ymhp9bla5waiybcbz86z-libvdpau-1.4-dev /nix/store/j3bgk3mqpz9qzxgf5ldn84s48z3708bd-SDL2-2.0.14-dev /nix/store/ykimxhzxp9ckkmz26rlsfxqv81rlg5bz-dav1d-0.9.0",
      "builder": "/nix/store/xxfxh4npdlp0w5winp2f17ji1yxdivn3-bash-4.4-p23/bin/bash",
      "configureFlags": "--arch=x86_64 --target_os=darwin --enable-gpl --enable-version3 --enable-shared --enable-pic --enable-runtime-cpudetect --enable-hardcoded-tables --enable-pthreads --disable-w32threads --disable-os2threads --enable-network --enable-pixelutils --enable-ffmpeg --disable-ffplay --enable-ffprobe --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avresample --enable-avutil --enable-postproc --enable-swresample --enable-swscale --disable-doc --enable-libass --enable-bzlib --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libmp3lame --enable-iconv --enable-libtheora --enable-libssh --disable-vaapi --disable-libdrm --enable-vdpau --enable-libvorbis --enable-libvpx --enable-lzma --disable-opengl --disable-libmfx --disable-libaom --disable-libpulse --enable-sdl2 --enable-libsoxr --enable-libx264 --enable-libxvid --enable-zlib --enable-libopus --enable-libspeex --enable-libx265 --enable-libdav1d --disable-debug --enable-optimizations --disable-extra-warnings --disable-stripping --cc=clang",
      "configurePlatforms": "",
      "depsBuildBuild": "/nix/store/9qiazds7s6qqmkqhvqgrygz74x7bvqhm-clang-wrapper-7.1.0",
      "depsBuildBuildPropagated": "",
      "depsBuildTarget": "",
      "depsBuildTargetPropagated": "",
      "depsHostHost": "",
      "depsHostHostPropagated": "",
      "depsTargetTarget": "",
      "depsTargetTargetPropagated": "",
      "dev": "/nix/store/2v2j1vwl63b9r0shc8db9rwz587spgrp-ffmpeg-4.4-dev",
      "doCheck": "",
      "doInstallCheck": "",
      "doc": "/nix/store/ivi69i2v9c77n3b2fgzfa5gg70k7i5ny-ffmpeg-4.4-doc",
      "enableParallelBuilding": "1",
      "enableParallelChecking": "1",
      "installFlags": "install-man",
      "man": "/nix/store/kn6dzh6ji59qqlk6niigvr0rg0pqmh3q-ffmpeg-4.4-man",
      "name": "ffmpeg-4.4",
      "nativeBuildInputs": "/nix/store/g3bxi35lvg77zgsngbyhicg8llj4jsrb-add-opengl-runpath /nix/store/4pn6m7hf6kk22zlkgdbnbnifk452k2h4-perl-5.32.1 /nix/store/ycp37qg19f9igkis6h7ccm83svg5jwaw-pkg-config-wrapper-0.29.2 /nix/store/phphykc87vj3qh9292si929h6j13jx17-texinfo-6.7 /nix/store/al4gidl7c4lyqbq0hc8cfhzhdc3ri277-yasm-1.3.0",
      "out": "/nix/store/8w2k9r3r1ra536csrh82pc3pb11hxh0r-ffmpeg-4.4",
      "outputs": "bin dev out man doc",
      "patches": "/nix/store/imbvmgxcd5b5mz3jj5mxkwlg7mwjlyf9-v2-0001-avcodec-videotoolboxenc-define-TARGET_CPU_ARM64-t.patch",
      "pname": "ffmpeg",
      "postFixup": "moveToOutput bin \"$bin\"\nmoveToOutput share/ffmpeg/examples \"$doc\"\nfor pc in ${!outputDev}/lib/pkgconfig/*.pc; do\n  substituteInPlace $pc \\\n    --replace \"includedir=$out\" \"includedir=${!outputInclude}\"\ndone\n",
      "postPatch": "patchShebangs .",
      "propagatedBuildInputs": "",
      "propagatedNativeBuildInputs": "",
      "setOutputFlags": "",
      "src": "/nix/store/6a0ghyfms7nm8db2q1pvgvb38h838psi-ffmpeg-4.4.tar.bz2",
      "stdenv": "/nix/store/b9h2w4nd3rg3hi9yga9ycpgppb5hl2p2-stdenv-darwin",
      "strictDeps": "",
      "system": "x86_64-darwin",
      "version": "4.4"
    }
  • your config file contains only my user name

Steps to reproduce

It happens every time. I have no way right now to run it without proxy.

Expected behaviour

All songs on the playlist should play.

Actual behaviour

Many songs on the playlist are skipped.

takeda avatar Jun 30 '21 18:06 takeda

It’s weird this affects only a few songs, not all. Do you have logs for your local proxy?

PromyLOPh avatar Jul 01 '21 06:07 PromyLOPh

I'm using ssh and added verbose logging when setting it up, but it doesn't look like it gives any useful information:

debug1: Connection to port 1080 forwarding to socks port 0 requested.
debug2: fd 7 setting TCP_NODELAY
debug1: channel 2: new [dynamic-tcpip]
debug2: channel 2: pre_dynamic: have 0
debug2: channel 2: pre_dynamic: have 4
debug2: channel 2: decode socks5
debug2: channel 2: socks5 auth done
debug2: channel 2: pre_dynamic: need more
debug2: channel 2: pre_dynamic: have 0
debug2: channel 2: pre_dynamic: have 24
debug2: channel 2: decode socks5
debug2: channel 2: socks5 post auth
debug2: channel 2: dynamic request: socks5 host tuner.pandora.com port 443 command 1
debug2: channel 2: open confirm rwindow 2097152 rmax 32768
debug1: Connection to port 1080 forwarding to socks port 0 requested.
debug2: fd 8 setting TCP_NODELAY
debug1: channel 3: new [dynamic-tcpip]
debug2: channel 3: pre_dynamic: have 0
debug2: channel 3: pre_dynamic: have 4
debug2: channel 3: decode socks5
debug2: channel 3: socks5 auth done
debug2: channel 3: pre_dynamic: need more
debug2: channel 3: pre_dynamic: have 0
debug2: channel 3: pre_dynamic: have 24
debug2: channel 3: decode socks5
debug2: channel 3: socks5 post auth
debug2: channel 3: dynamic request: socks5 host tuner.pandora.com port 80 command 1
debug2: channel 3: open confirm rwindow 2097152 rmax 32768

The first connection got 403 but 2nd worked, but both seem the same except 2nd uses port 80... interesting.

takeda avatar Jul 01 '21 17:07 takeda

Do you see connections to any host other than tuner.pandora.com? It only serves the API, but not audio files.

PromyLOPh avatar Jul 02 '21 06:07 PromyLOPh

No, those were the only connections that showed up.

Is it possible that none of the music files actually go through the proxy?

I just realized that my network also returns 403 for domains ending in pandora.com so perhaps some audio files are hosted from a different domain?

takeda avatar Jul 02 '21 07:07 takeda

I noticed that "Unable to open audio file " error happens when avformat_open_input() fails. I also found this: https://trac.ffmpeg.org/ticket/5776. Maybe the problem is that FFMPEG doesn't support SOCKS proxy?

takeda avatar Jul 02 '21 07:07 takeda

Oh, you’re right, audio files go through ffmpeg directly and not through curl. ffmpeg is probably ignoring your ALL_PROXY environment variable and/or does not support socks.

PromyLOPh avatar Jul 02 '21 07:07 PromyLOPh

So I just set up privoxy to convert SOCKS5 to HTTP proxy and used http_proxy=http://127.0.0.1:8118 and I think it works.

I see request to tuner.pandora.com but also to audio-sv5-t1-1-v4v6.pandora.com and t1-5.p-cdn.us. I suspect the domains like that one weren't blocked and that's why I got some songs to work, while others didn't.

I'm assuming pianobar can't do much about it and I should try my luck with FFMPEG?

takeda avatar Jul 02 '21 17:07 takeda

Well, we could fetch audio files through libcurl and gain proxy support, but I’d rather stick with ffmpeg, because the playback code is complicated enough as it is. So yeah, ffmpeg with SOCKS proxy support would really help here.

PromyLOPh avatar Jul 03 '21 06:07 PromyLOPh

Is there any guide to set up a workaround properly? When I launch pianobar I sometimes get 403 errors for everything until I stop and restart it. It takes 3 to 4 attempts to get it working.

aragaer avatar Aug 10 '21 06:08 aragaer

@aragaer, So here's how I do it:

create SOCKS proxy through SSH (this opens socks on localhost:1080)

ssh -vND 1080 <host>

configure privoxy (this opens http proxy on localhost:8118)

privoxy.config:

listen-address 127.0.0.1:8118
forward-socks5 . localhost:1080 .
logfile /dev/stdout
debug 1

start privoxy

privoxy --no-daemon privoxy.config

start pianobar

http_proxy=http://127.0.0.1:8118 pianobar

takeda avatar Nov 05 '21 00:11 takeda