Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot assign requested address #33

Closed
Jorman opened this issue Mar 14, 2020 · 1 comment
Closed

Cannot assign requested address #33

Jorman opened this issue Mar 14, 2020 · 1 comment

Comments

@Jorman
Copy link

Jorman commented Mar 14, 2020

Hi, the situation is pretty strange, and I'm not so able to understand why this happens, I'll try to explain what is and when happen the error.
I wrote a little bash script to extract listening port with this command
ACTUAL_QBITTORRENT_PORT=$($QBT_BIN server settings connection --username "$QBITTORRENT_USERNAME" --password "$QBITTORRENT_PASSWORD" --url "http://${QBITTORRENT_HOST}:$QBITTORRENT_PORT" --format json | $JQ_BIN '.ListenPort')
When I run it inside putty shell all works, the same when I use it from command line, but if I call the script from a systemd system I get the "Cannot assign requested address" error.
So this's the output if I launch the script

+ OWRT_UNAME=root
+ OWRT_IP_ADDR=10.0.0.1
+ QBITTORRENT_HOST=localhost
+ QBITTORRENT_USERNAME=admin
+ QBITTORRENT_PASSWORD=adminadmin
+ QBITTORRENT_PORT=8081
+ LOG_ENABLE=0
+ LOG_PATH=/tmp
+ [[ 0 == 1 ]]
+ [[ 0 == 1 ]]
++ command -v qbt
+ QBT_BIN=/usr/bin/qbt
++ command -v ssh
+ SSH_BIN=/usr/bin/ssh
++ command -v jq
+ JQ_BIN=/usr/bin/jq
+ [[ -z /usr/bin/qbt ]]
+ [[ -z /usr/bin/ssh ]]
++ /usr/bin/ssh root@10.0.0.1 'cat /tmp/pia-port-forward'
+ REMOTE_PIA_PORT=46786
+ [[ -n 46786 ]]
++ /usr/bin/qbt server settings connection --username admin --password adminadmin --url http://localhost:8081 --format json
++ /usr/bin/jq .ListenPort
+ ACTUAL_QBITTORRENT_PORT=46786
+ [[ 46786 == 46786 ]]
+ [[ 0 == 1 ]]

And this's the output when I call the script from the systemd

Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + OWRT_UNAME=root
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + OWRT_IP_ADDR=10.0.0.1
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + QBITTORRENT_HOST=localhost
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + QBITTORRENT_USERNAME=admin
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + QBITTORRENT_PASSWORD=adminadmin
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + QBITTORRENT_PORT=8081
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + LOG_ENABLE=0
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + LOG_PATH=/tmp
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ 0 == 1 ]]
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ 0 == 1 ]]
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: ++ command -v qbt
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + QBT_BIN=/usr/bin/qbt
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: ++ command -v ssh
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + SSH_BIN=/usr/bin/ssh
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: ++ command -v jq
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + JQ_BIN=/usr/bin/jq
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ -z /usr/bin/qbt ]]
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ -z /usr/bin/ssh ]]
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + REMOTE_PIA_PORT=1234
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ -n 1234 ]]
Mar 14 16:46:36 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: ++ /usr/bin/qbt server settings connection --username admin --password adminadmin --url http://localhost:8081
Mar 14 16:46:40 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: Cannot assign requested address
Mar 14 16:46:40 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + ACTUAL_QBITTORRENT_PORT=
Mar 14 16:46:40 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + echo ''
Mar 14 16:46:40 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ '' == 1234 ]]
Mar 14 16:46:40 Qnap qBittorrent_OPENWRT_Pia_Port.sh[29617]: + [[ 0 == 1 ]]

As you can see, the ACTUAL_QBITTORRENT_PORT var is not valid because of "Cannot assign requested address" error

Do you've any idea?

@Jorman
Copy link
Author

Jorman commented Mar 14, 2020

Never mind, I found the problem, was my fault, I used ExecStartPre instead ExecStartPost so qbt was launched before qbittorrent and not after!
So, no worry.

J

@Jorman Jorman closed this as completed Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant