rTorrent/Ubuntu

Here are the steps to install Transdroid when you use rTorrent on Ubuntu:

Compiling and installing rTorrent

For the ideal rTorrent/Transdroid set-up, we need to compile a fresh new version with support for 64-bit integers. A word of warning: rTorrent is primarily for the advanced Linux user. However, I hope this guide will help you through the whole process. A lot is taken from the excellent install guide for wTorrent, a web UI for rTorrent.

First install the necessary dependencies:

sudo apt-get install subversion build-essential libtool automake1.9 openssl libcurl3 libcurl3-dev libsigc++-2.0-0c2a libsigc++-2.0-dev libncurses5 libncurses5-dev libcppunit-dev

I also assume you have a running Lighttpd or Apache webserver. Now, make a working directory and change into it…

mkdir build
cd build

We need xmlrpc-c and xmlrpc-c-dev of version 1.07 or higher. The minimum Ubuntu version that has these is Natty, so if you are running an older version we get the .deb files manually from the Ubuntu packages site: libxmlrpc-c3-0 and libxmlrpc-c3-dev are needed and availble for i386 and amd64. Choose the packages for your architecture and place them in the working directory. Install it using aptitude. Remember to adjust the file names to your downloaded .debs:

sudo apt-get dpkg -i libxmlrpc-c3-0_1.16.32-0ubuntu3_amd64.deb
sudo apt-get dpkg -i libxmlrpc-c3-dev_1.16.32-0ubuntu3_amd64.deb

Time to install libTorrent and rTorrent. Download the latest version of both from their homepage. Adjust the file names accordingly in the next compile/install commands:

tar xvzf libtorrent-0.12.6.tar.gz
cd libtorrent-0.12.6
./autogen
./configure
make
sudo make install
cd ..
tar xvzf rtorrent-0.8.6.tar.gz
cd rtorrent-0.8.6
./autogen.sh
./configure --with-xmlrpc-c
make
sudo make install
cd ..

If the compiling was successful, rTorrent should now be installed and ready to use. You may try it by running ‘rtorrent’. To exit the program press Ctrl+Q. The next step is to enable the RPC functionality of rTorrent. Since I assume here we have a fresh install, you should first get a configuration file. Download it from the rTorrent website and place it in your home dir, renaming it to .rtorrent.rc:

wget http://libtorrent.rakshasa.no/export/1290/trunk/rtorrent/doc/rtorrent.rc
mv rtorrent.rc ~/.rtorrent.rc

You need to add the following two lines to that configuration file:

scgi_port = 127.0.0.1:5000
xmlrpc_dialect=i8

To also protect incoming connections on this SCGI port, we’ll password-protect it in the next step.

The last step is to configure the web server. Lighttpd and Apache with mod_scgi are supported. I have not tested it with Lighttpd myself, but the install instructions are here. For apache you need to install and enable mod_scgi support first:

sudo apt-get install libapache2-mod-scgi
sudo a2enmod scgi

You might get warnings that you already installed/enabled this. That’s okay of course. Next you need to add the SCGI mount for rTorrent. Open up /etc/apache2/sites-available/default with superuser rights, for example:

gksudo gedit /etc/apache2/sites-available/default &

And add the following lines at the near-end of the document, just before the line that says ‘</VirtualHost>’:

SCGIMount /RPC2 127.0.0.1:5000
<location /RPC2>
AuthName "rTorrent secure access"
AuthType Basic
AuthBasicProvider file
AuthUserFile /home/yourusername/Documents/rtorrent-htpasswd
Require user yourusername
</location>

Of course you replace ‘yourusername‘ with your own username. I named the password file (we will be creating that next) rtorrent-htpasswd and placed the file in my Documents dir, but you are free to place it anywhere you like and call it differently. Indeed that’s what we do here; set the password for your user:

htpasswd -c /home/yourusername/Documents/rtorrent-htpasswd yourusername

You may want to install wTorrent as well. Since you already have a rTorrent set-up with XML-RPC this isn’t very hard. You can get it from the wTorrent website.

Restart your webserver now to activate all the changes:

sudo /etc/init.d/apache2 restart

wTorrent: a web interface for rTorrent

We’re done! Remember that you always need to have rtorrent running to be able to connect to it using Transdroid. Since rTorrent does not run as a daemon, you may want to use screen to start and control remote session of rTorrent.

Allow access from anywhere

The next step is very important if you want to use Transdroid to control rTorrent from anywhere you go and not just your home Wi-Fi network. If you have not yet opened up your web port (port 80), you will need to do so here and redirect this to your home computer. Get your local IP by looking at the output for your external network adapter (most likely eth0) from running the command:

ifconfig

Now go to your the manager interface of your router or ADSL modem. It will most likely have a NAT tab or settings screen. Here you will need to set up a port forward from all external traffic on port number 80 to you local computer’s IP address on the same port. There are too many routers and ADSL modems to make detailed explanations here, but you can use the website PortForward for in-depth help.

Setting up Transdroid

The final step is to set up Transdroid. Install the software from the Android Market and open up the application. You will see a message that you need to set up a server configuration first. Hit your Android device’s menu button and choose ‘Settings’. Next, click the ‘Add a sever’ button to create your first sever configuration. You can add more later, if you need to.

Now fill in all the settings. The name is totally up to you. From the type menu you choose for rTorrent of course.

The IP address is your server’s external IP address. If you do not know this, open up a browser on your Ubuntu machine and surf to whatismyip.com. It will present you the external IP address that you need in Transdroid.

The port number should be set to 80 and the SCGI folder should be ‘/RPC2′. Unless, of course, you have made a different, custom Lighttpd/Apache configuration.

Setting the SCGI filder in Transdroid

Choose to enable authentication and fill in the username and password that you created.

Time to test your settings! First disconnect from the Wi-Fi network if you are connected to the local network (the one where your Ubuntu machine is in as well). This is important, because you will need to use different settings for that.

Now, hit the back button of your Android device twice to return to the main screen. It should now state that it is connecting to the sever. After a couple of seconds you should get a listing of all the active torrents in rTorrent. Rewards yourself by downloading some torrents, right from your phone. :)

Local Wi-Fi network access

One thing you should know when you have a Wi-Fi network at home, is that you cannot use your external IP address as described above while you are connected this way. When connected to the wireless network that your Ubuntu machine is in, you will need to use your machine’s internal IP address instead.

Easiest thing to do is to open Transdroid’s settings menu again and add a new sever configuration. Use the exact same details that you used before, but now use your Ubuntu machine’s local IP address. Of course you also want to give it a name that identifies it as being your local configuration.

Give it a test by going to the main screen and choose ‘servers‘ from the menu. You can select the other configuration from the pop-up menu. A little tip: switching servers can also be done by swiping your finger from left to right (or the other way around). No need to open the menu each time!

Troubleshooting

If Transdroid refuses to connect you, use these steps to trace the problem.

When starting rTorrent, it should say something like ‘XMLRPC initialized …’ and ‘The SCGI socket has not been bound to any address…’. If not, please enable XML-RPC in your .rtorrent.rc configuration file.

You may want to install the wTorrent web interface for rTorrent. Besides being really useful from time to time, you can also use it to tes tyour setup. If you open it (usually on http://localhost/wtorrent/) from your Ubuntu machine and it is not able to connect, then rTorrent is not started or the SCGI redirection is not set up correctly.

If you can connect to your rTorrent server using Transdroid from your inside Wi-Fi network, but cannot connect from the outside (using 3G/EDGE), then your port forwarding is not correct. Fix it by (re)creating the NAT rule on your router/ADSL modem.

Still having troubles? Use the ‘error report’ feature in Transdroid’s menu to get personal help.

Good luck and enjoy!

19 comments

Comments are closed. Please use the support forum instead.
  1. Keefe says:

    “You need to add the following two lines to that configuration file:
    scgi_port = :5000″

    “This will expose the web UI to every IP address, even from the outside, but that’s exactly what we want here. We’ll password-protect it in the next step.”

    I think you are leaving rtorrent wide open to the world. You’re telling rtorrent to listen for connections from anywhere. Then you setup the translation module SCGIMount in apache and restrict access to it by password. Sure, now access through SCGIMount is password protected, but direct access to rtorrent itself is still wide open. All one needs to do is put this line in their own webserver configuration:
    SCGIMount /RPC2 :5000
    And voila they have password-free access to your rtorrent.

    You don’t need to have rtorrent listening to anyone but 127.0.0.1, so make rtorrent’s configuration like this:
    scgi_port = 127.0.0.1:5000
    SCGIMount in apache will connect to rtorrent locally, and will provide only password-protected access to the world.

    • Keefe says:

      Oops, part of my post didn’t show properly. This is what I meant:

      All one needs to do is put this line in their own webserver configuration:
      SCGIMount /RPC2 YOUR_IP:5000

    • Eric Kok says:

      Keefe, you are right. You only need to expose the RPC-XML API to your localhost; I changed this in the install guide.

      Note that it was only a real security risk when you had port 5000 opened, but it’s still good to fix this.

  2. Anonymous says:

    Thanks!

    This solved my troubles :D

  3. sirius2834 says:

    Hi,

    I would like to thank you for this superb install guide. This was the first one ever that included ALL the necessary steps to config and use rtorrent. Thanks a lot :-)

  4. aidan says:

    I’m using Ubuntu 10.04, but didn’t bother using the latest version or libxmlrpc, and I found that if I remove xmlrpc_dialect=i8 from the config file – it still works.

    But, I can’t seem to add torrents from transdroid. Is this a likely side effect?

    Thanks for your great app!

  5. Ejal de Klerk says:

    I didn’t have autogen on my system, maybe you should add that to the build requirements :)

  6. Vampire says:

    The building/installation is possible very much easier:

    - Download the libxmlrpc-c3 experimental debian packages
    - sudo apt-get remove libxmlrpc-c3 libxmlrpc-core-c3
    - sudo dpkg -i libxmlrpc-c3_1.16.07-1_amd64.deb libxmlrpc-c3-dev_1.16.07-1_amd64.deb
    - mkdir build_rTorrent && cd build_rTorrent
    - sudo apt-get build-dep rtorrent
    - apt-get -b source rtorrent
    - sudo dpkg -i rtorrent_0.8.2-0ubuntu2_amd64.deb
    - sudo /etc/init.d/rtorrent start
    - cd .. && rm -rf build_rTorrent

  7. Vampire says:

    What I posted is what I actually did and this works fine. The –with-xmlrpc-c flag is set in the ubuntu source, so this doesn’t need to be set explicitly. The only problem with the packages provided by Ubuntu is that they are built against the too old version of libxmlrpc-c3.

  8. Big_Gray says:

    why you don’t control rtorrent simply through ssh with or without screen? Like as nTorrent (may be found on sourceforge.net under GPL license). On embedded devices such as routers this may save resources – not need to install scgi, web-server and other stuff.

    P.s. sorry for my english

  9. Vampire says:

    Big_Gray, I’m controlling rtorrent through the ncurses interface usually, but e. g. on my Android phone I have a widget for the start screen that shows me current stats about my downloads and automatically informs me if a download finished and that is VERY useful but needs the 64-bit integer support for big files being displayed correctly.

  10. Vampire says:

    @Eric One addition to my sequence of commands. As long as you don’t change the version number, the package management tries to reinstall the official version for the custom build one, including a dependency which is not compatible with the debian version of libxmlrpc-c3, so there should be the version number increased. Here is the new list of steps if you want to include it in the main entry:

    - Download the libxmlrpc-c3 experimental debian packages
    - sudo apt-get remove libxmlrpc-c3 libxmlrpc-core-c3
    - sudo dpkg -i libxmlrpc-c3_1.16.07-1_amd64.deb libxmlrpc-c3-dev_1.16.07-1_amd64.deb
    - mkdir build_rTorrent && cd build_rTorrent
    - sudo apt-get build-dep rtorrent
    - apt-get source rtorrent
    - Edit rtorrent-0.8.2/debian/changelog and change the version number in the first line from 0.8.2-0ubuntu2 to 0.8.2-0ubuntu3
    - dpkg-buildpackage -rfakeroot -uc -b
    - sudo dpkg -i rtorrent_0.8.2-0ubuntu3_amd64.deb
    - sudo /etc/init.d/rtorrent start
    - cd .. && rm -rf build_rTorrent

  11. bardic says:

    Hey,I’ve followed your guide and rtorrent works just fine and starts up. But wTorrent can’t fine it. Any idea’s?

    • Eric Kok says:

      For install support of wTorrent, please ask the developers of wTorrent or go to there website. I don’t use wTorrent myself, sorry.

Trackbacks /
Pingbacks

  1. Testimonial | Seed My Box