Open danlii opened 5 years ago
Hi!, thanks for taking the time to raise an issue and apologies for the delayed reply!
Yes, Tizonia currently does not explicitly support configuration of an http proxy for Spotify or any of the other services. I'm not sure at this point if libspotify supports this somehow. If that was the case, then it would be relatively easy to add this configuration option into tizonia.conf.
I don't have a timeframe for when this could be done (or checked at least) so any help from the community on this would be greatly appreciated.
Well, I'm not a programmer, so I don't know if libspotify supports proxy or not. However, I found references to it here: https://pyspotify.mopidy.com/en/v2.0.5/api/config/ - although I must confess that I don't know if that page is relevant in this case or not.
@danlii
I've just checked this and I believe there is a possibility to pass the proxy configuration to libspotify (which is the underlying mechanism used by both mopidy, Tizonia and other open-source tools that currently stream from Spotify).
I'll look into that sometime, but this should not be too difficult to implement.
This is now work-in-progress, in the 'develop' branch. Proxy settings can be provided (for use with Spotify only) via
izonia --help proxy
tizonia 0.18.0. Copyright (C) 2019 Juan A. Rubio
This software is part of the Tizonia project <http://tizonia.org>
GNU Lesser GPL version 3 http://gnu.org/licenses/lgpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Proxy server options:
--proxy-server arg Url to the proxy server that should be used (only works
with the Spotify service at the moment, not required if
provided via config file). The format is
protocol://
- Tizonia's configuration file
#
- currently NOT via an environment variable like http_proxy or https_proxy.
@danlii would you be able to test the proxy feature using a pre-release build that I would upload here?
The code has been merged to master. Closing this issue for now.
Seems like it's not working.
Using tizonia 0.19.0
, tried setting in tizonia.conf as well as passed into the command line.
Used an invalid proxy address to check and it could still play spotify tracks with no issues. Made sure cache is removed just in case as well.
Used random values in tizonia.conf
, tested with just proxy.server
and then with proxy.user_name
and proxy.user_password
as well.
# HTTP proxy server configuration
# -------------------------------------------------------------------------
# NOTE: Proxy configuration is currently only available with the Spotify
# service. It will be ignored with other music services.
#
proxy.server = http://123.1.123.123:8089
#Url to the proxy server that should be used.
# The format is protocol://<host>:port (where protocol
# is http/https/socks4/socks5). E.g.: http:some.proxy.net:1234
proxy.user_name = asdwbrqqwb
#Username to authenticate with proxy server
proxy.user_password = dsadwbdaw
#Password to authenticate with proxy server
As for passing in via CLI:
tizonia --proxy-server http://123.1.123.123:8089 --spotify-track-id spotify:track:0xPHALeBb3aLEZrj0T0R2P
Tested as much as I could, these are my findings:
ONLY export https_proxy=xxx.xx.xx.xx:xxxx
works.
Setting http_proxy
via export http_proxy=...
, using tizonia.conf
or passing in --proxy-server
via cli did not work.
Also @juanrubio , the documentation/notes at d22523a6e7ecc9798f245f7a0dd5c87088c73ce7 e77deffe4abb3232fc3469f7a2a70cdecb964f6f and 35c9732d7b631484accc2d6b19ad577f07502eea are wonky. For example in d22523a6e7ecc9798f245f7a0dd5c87088c73ce7 , it first states
The format is protocol://<host>:port (where protocol
# is http/https/socks4/socks5).
and then
E.g.: http:some.proxy.net:1234
I guess the second part should be http://some.proxy.net:1234
?
When doing the export https_proxy=...
method,
Hi @evilmtv!
thank you so much for investigating this. Really interesting findings. I need to look into them in detail. I'm re-opening this issue.
Would you like to submit a PR with the documentation fixes?. That would be really appreciated.
I'd like to get that done but I'm not 100% sure if what I'm assuming is the correct format is indeed the correct format. Also not sure if protocols other than https will work. I looked through the relevant commits but couldn't understand how it's being done.
Very good point. Essentially, tizonia simply passes the information to the libspotify API.
You can see the doxygen information in your system in (if you have installed tizonia) under /usr/include/libspotify/api.h
(see also https://github.com/mopidy/libspotify-archive)
/**
* Url to the proxy server that should be used.
* The format is protocol://<host>:port (where protocal is http/https/socks4/socks5)
*/
const char *proxy;
From your analysis it is interesting that libspotify seems to be honoring the http_proxy
environment variable, which is something that tizonia is not even touching. However, when the proxy config is passed via command-line options or configuration file is when the problems arise. Here is where tizonia does intervene. So something is amiss there.
Minor correction to your statement, its https_proxy
, not http_proxy
Upon further digging, it seems that there are two connections,
https_proxy
and all_proxy
environment variable. So far using a http and https proxy works when using all_proxy
. Unconfirmed if other protocols works. But whatever is set, 'logging in' will adhere to the proxy rules.
Note: I used an invalid SOCKS5 proxy and it was unsuccessful as expected, meaning it is attempting to use the set proxy.I tested this via using Ubuntu's built in firewall ufw
~$ sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), deny (outgoing), deny (routed)
New profiles: skip
To Action From
-- ------ ----
22/tcp ALLOW IN Anywhere
8811 ALLOW IN Anywhere
22/tcp (v6) ALLOW IN Anywhere (v6)
8811 (v6) ALLOW IN Anywhere (v6)
8811/tcp ALLOW OUT Anywhere
22 ALLOW OUT Anywhere
8811/tcp (v6) ALLOW OUT Anywhere (v6)
22 (v6) ALLOW OUT Anywhere (v6)
where 8811 is the proxy port. It had no issues logging in but will fail to stream.
$ tizonia --proxy-server http://36.89.181.161:50204
tizonia 0.19.0. Copyright (C) 2019 Juan A. Rubio
This software is part of the Tizonia project <http://tizonia.org>
[Spotify] [Connecting] : 'REDACTED'.
[Spotify] [Track id] 'REDACTED'.
[Spotify] [Track] REDACTED.
[Spotify] [Tracks in queue] '1'.
[Spotify] [Cache]: '/var/tmp/tizonia-REDACTED'
Hope this helps with fixing it. I'd like to help but I highly doubt I'll be able to understand the code fast.
Tried to dig through the code for lines containing 'proxy' but only noticed this section with minor inconsistencies, the 'const' and the brackets. Not sure if that matters anyway.
Is there anything wrong with section below? https://github.com/tizonia/tizonia-openmax-il/blob/eed901e408ffcb9ab2527ce37670fcf4bd0439fe/plugins/spotify_source/src/spfysrcprc.c#L1600-L1612
Hi Jun!
First of all, I'm very impressed. Great stuff!. I must admit I have no idea what's going on. I need to find a little bit of time to look into this in detail.
Regarding this section, I'm basically trying to find out if the proxy configuration is not empty.
if (p_prc->session_.cProxyServer
&& 0 != strncmp ((char *) p_prc->session_.cProxyServer, "",
OMX_MAX_STRINGNAME_SIZE))
I believe it does the job.
If you export this environment variable, Tizonia will output some colored debug messages on your console:
export TIZONIA_DEBUG_COLOR_TRACE=1
with this exported and running Tizonia like this:
t --spotify-tracks 'all right now' --proxy-server http://36.89.181.161:50204
I can see this output
[spfysrcprc.c:spfysrc_prc_allocate_resources:1609] --- cProxyServer: http://36.89.181.161:50204
[spfysrcprc.c:spfysrc_prc_allocate_resources:1610] --- cProxyUserName:
[spfysrcprc.c:spfysrc_prc_allocate_resources:1611] --- cProxyPassword:
The https_proxy
environment variable is not used by tizonia, so if this has any effect on what tizonia does, it must becase either pyspotify or libspotify are reading the variable. We need to find which one.
Good morning, Do you have any news about this problem? I have the same issue with proxy. Thank you.
Hi @rcandelu,
sorry, I have not looked into this yet.
Description
When using tizonia behind a proxy, it tries to make a direct connection to Spotify and fails.
Steps to Reproduce
Expected behavior: Since I have the environment variable "http_proxy" set, I expected tizonia to honor that. That same proxy setting is what I use in the official Spotify client, and that works.
Actual behaviour: The song never starts.
Reproduces how often: 100%
Versions
%:~>tizonia --version tizonia 0.18.0. Copyright (C) 2019 Juan A. Rubio This software is part of the Tizonia project http://tizonia.org
%:~>tizonia --debug
tizonia 0.18.0. Copyright (C) 2019 Juan A. Rubio This software is part of the Tizonia project http://tizonia.org
Debug Info:
%:~>cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
Installation Method Used
deb repo