Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Flood hangs after logging in, but "works" when quitting rtorrent? #761

Open
NoLooseEnds opened this issue Jan 31, 2019 · 36 comments
Open

Flood hangs after logging in, but "works" when quitting rtorrent? #761

NoLooseEnds opened this issue Jan 31, 2019 · 36 comments

Comments

@NoLooseEnds
Copy link

NoLooseEnds commented Jan 31, 2019

Your Environment

  • Version used:
    • Version (stable release) Latest version pulled from git
  • Environment name and version:
    • Node.js version 8.14.0
    • npm version 6.4.1
    • Web browser Chrome 71.0.3578.98 (Official Build) (64-bit)
  • Operating System and version: Alpine Linux (Docker)

Summary

Flood hangs after logging in, but as soon as rtorrent quits it loads up and get the data?

The weird thing is that Flood "has the data" when it loads after quiting rtorrent (and flood, since they are in the same dockerfile)

See video:
flood-hd 720p

Expected Behavior

Flood loading up the interface as normal.

Config files

docker-compose.yml:


services:
  openvpn-client:
    container_name: openvpn-client
    image: dperson/openvpn-client
    restart: unless-stopped
    # cap_add, security_opt, and volume required for the image to function
    cap_add:
      - net_admin
    environment:
      TZ: '${TZ}'
      FIREWALL: ''
      ROUTE: '10.0.0.0/24'
    networks:
      - system_default
    ports:
      - "49184:49184" #rtorrent
    read_only: true
    tmpfs:
      - /run
      - /tmp
    security_opt:
      - label:disable
    stdin_open: true
    tty: true
    volumes:
      - /dev/net:/dev/net:z
      - ./openvpn:/vpn
    labels:
      - "traefik.port=3000"
      - "traefik.frontend.rule=PathPrefixStrip:/flood"

  rtorrent:
    container_name: rtorrent
    build: rtorrent-flood
    #image: wonderfall/rtorrent-flood
    tty: true
    restart: on-failure
    network_mode: "service:openvpn-client"
    volumes:
      - ./rtorrent-flood/config:/config
      - ./rtorrent-flood/data:/data
      - ./rtorrent-flood/flood-db:/flood-db

networks:
  system_default:
    external: true

config.js:

const CONFIG = {
  baseURI: process.env.FLOOD_BASE_URI || '/flood',
  dbCleanInterval: 1000 * 60 * 60,
  dbPath: '/flood-db/',
  floodServerHost: '0.0.0.0',
  floodServerPort: 3000,
  maxHistoryStates: 30,
  pollInterval: 1000 * 5,
  secret: process.env.FLOOD_SECRET || 'xxx',
  scgi: {
    host: 'localhost',
    port: 5000,
    socket: true,
    socketPath: '/tmp/rtorrent.sock'
  }
};

module.exports = CONFIG;

.rtorrent.rc

scgi_local = /tmp/rtorrent.sock

encoding_list = UTF-8
port_range = 49184-49184
port_random = no
check_hash = no
directory = /data/torrents
session = /data/.session
encryption = allow_incoming, try_outgoing, enable_retry
trackers.use_udp.set = yes
dht.mode.set = off
protocol.pex.set = no

min_peers = 1
max_peers = 100
min_peers_seed = 1
max_peers_seed = 50
max_uploads = 15

network.xmlrpc.size_limit.set = 10000000

schedule = watch_directory,1,1,"load.start=/data/.watch/*.torrent"
schedule = untied_directory,5,5,"stop_untied=/data/.watch/*.torrent"
schedule = scgi_permission,0,0,"execute.nothrow=chmod,\"g+w,o=\",/tmp/rtorrent.sock"
schedule = insufficient_disk_space,1,30,close_low_diskspace=500M
@NoLooseEnds
Copy link
Author

I've tried a bit more, but I'm still stuck. I'm now trying to debug with a dedicated rtorrent and a dedicated flood docker image (instead of combining them).

I've figured out:

  • The interface load when I quit flood, not rtorrent (as I previous thought)
  • I got the same "reaction" both if I use socket-file, and if I use ip:port.

No idea why it's behaving this way.

@NoLooseEnds
Copy link
Author

NoLooseEnds commented Feb 5, 2019

This seem to be an issue caused by using Traefik and a non-default pathURI (i.e /flood instead of /. Not sure witch is causing it, but I'm thinking Flood, since it sort of loads up (hence Treaefik working), but is just stuck on the "loading screen".

@NoLooseEnds
Copy link
Author

Looking into this again. Still stuck, but I think I've narrowed it down further.

  • non default path, does not matter for this issue (except for modifying the config.js correctly), I've switched to subdomain and it still behaves this way.

I'm trying to route the rtorrent and flood docker via an openvpn-client docker, and that is breaking it. network_mode: "service:openvpn-client"

Why does Flood halt, as long as it has access to the socket it should not care? Makes no sense. It serves files fine, but will not let me past the loading icon.

flood             |
flood             | > [email protected] start /usr/flood
flood             | > node server/bin/start.js
flood             |
flood             | Flood server starting on http://undefined:3000.
flood             |
flood             | GET /overview 200 12.714 ms - 543
flood             | GET /static/css/main.16a9269d.css 200 9.979 ms - -
flood             | GET /static/js/main.bbb83ce9.js 200 13.268 ms - -
flood             | GET /static/media/Roboto-500.1afbee5a.woff2 200 3.429 ms - 10248
flood             | GET /static/media/Roboto-700.3b38c16e.woff2 200 7.463 ms - 10276
flood             | GET /auth/verify?1551966088456 401 7.575 ms - -
flood             | GET /api/activity-stream?historySnapshot=fiveMin 401 0.261 ms - -
flood             | POST /auth/authenticate 200 44.647 ms - 211
flood             | GET /api/settings 200 20.859 ms - 2
flood             | GET /overview 200 1.229 ms - 543
flood             | GET /api/activity-stream?historySnapshot=fiveMin 200 10.966 ms - -
flood             | GET /api/client/settings - - ms - -
flood             | GET /static/js/main.bbb83ce9.js 304 1.286 ms - -
flood             | GET /static/css/main.16a9269d.css 200 4.375 ms - -
flood             | GET /static/media/Roboto-500.1afbee5a.woff2 304 1.085 ms - -
flood             | GET /static/media/Roboto-700.3b38c16e.woff2 304 3.120 ms - -
flood             | GET /auth/verify?1551966109737 200 3.023 ms - 52
flood             | GET /api/settings 200 1.130 ms - 2

@NoLooseEnds
Copy link
Author

NoLooseEnds commented Mar 8, 2019

I've tried to digg a bit more:

Just to make sure I didn't configure something wrong with keeping flood and rtorrent as separate docker images, I tested with a different docker image (linuxserver/flood) that combines rtorrent and flood into one image.

It still halted on login. So from there I disconnected/removed the network_mode: "service:openvpn-client" and ran it "vanilla". Still did not work.

Then I sort of had an breaktrough – I tested opening the docker host address/url:3000, and that worked. I tried the same on the traefik address/url, and that did not work. That just loads the username/password box, and then it halts on the loading screen.

The logs from flood shows it loads the exact same files when it works (via docker host and via the traefik host). So I don't understand whats going on.

At least it looks like I've narrowed it down to that Traefik is breaking something with flood (or vica versa).

Does anyone have any clue? @noraj @jfurrow

@noraj
Copy link
Contributor

noraj commented Mar 8, 2019

You're using a third-party docker image (from linuxserver) and an untest OS (Traefik) and making teh whole thing going through a VPN.
Why don't you use the docker image provided in this repo?
I don't know it may be your VPN configuration.

All I can tell is that this is the recommended way to install: https://rawsec.ml/en/archlinux-install-rtorrent-flood-sftp/

Try to reproduce that in some docker containers.

@noraj noraj removed the bug label Mar 8, 2019
@NoLooseEnds
Copy link
Author

NoLooseEnds commented Mar 8, 2019

I don't think you read my previous post that well (or I was unclear).

I've run a lot of docker images, both the dockerfile from this repo and others, to try see if they did anything different (including docker images that combine rtorrent and flood in one image, and not in two separate). I've also done it with and without routing it through a VPN container – and that makes no difference.

Traefik is not an OS, it is an awesome reverse proxy.

Everything works if I use the docker host as the URL on port 3000 (ie. dockerhostname.subdomain.TLD:3000), but Flood hangs/stops on the loading screen if I use the Traefik host (ie. flood.subdomain.TLD).

Hence the issue is between Traefik and Flood somewhere. But I have no idea why. Everything else works with Traefik (including rutorrent, and a lot of other non torrent related services).

If I'm guessing, it could be something with the http headers, but I'm not skilled enough to figure that out as of yet.

@noraj
Copy link
Contributor

noraj commented Mar 8, 2019

Ok so whatever is Traefik you're trying to use it as a reverse proxy. So basically you can take a look of what I did with Nginx (https://rawsec.ml/en/archlinux-install-rtorrent-flood-sftp/#configure-nginx) or the wiki (https://github.com/jfurrow/flood/wiki/Using-Flood-behind-a-reverse-proxy).
Only a simple proxy pass should be needed but if you are using http 2 on the edge side you may need to specify to use http 1.1 for the app side (proxy_http_version 1.1; with nginx).
There is no bug of flood here. I think this is just about configuring your reverse proxy correctly.

@NoLooseEnds
Copy link
Author

NoLooseEnds commented Mar 9, 2019

That's the thing, afaik I'm not doing anything special (and all other services works fine – i.e I'm currently running Sonarr, Radarr and Jacket containers routed via the VPN container with the exact same reverse proxy (traefik) settings – and that works flawlessly. ).

And the reverse proxy (traefik) is sort of working (i.e it loads up the login (or setup) screen), but hangs when logging in.

flood-hd 720p

So something is going on at that moment, when it is trying to log you in.

@noraj
Copy link
Contributor

noraj commented Mar 10, 2019

@noraj
Copy link
Contributor

noraj commented Mar 10, 2019

I never saw this scgi block in config.js. and I never succeed to make rtorrent works with flood using an UNIX socket, so I'm using a local tcp connection.

@NoLooseEnds
Copy link
Author

Thanks, but the setup works fine when you access the host directly in the browser i.e dockerhost:3000, but hangs when logging in if you if you access it via the reverse proxy on flood.subdomain.TLD. And you can test both ways simultaneously.

So there is something with flood and traefik that I can't figure out.

@noraj
Copy link
Contributor

noraj commented Mar 10, 2019

If directly accessing the docker is fine, it must be an issue with traefik.
As I said previously, look at https://rawsec.ml/en/archlinux-install-rtorrent-flood-sftp/#configure-nginx and try to adapt and reproduce what I did.
I'll close this issue as it is not a bug from flood.
Please go to the discord if you want to ask for support.

@noraj noraj closed this as completed Mar 10, 2019
@NoLooseEnds
Copy link
Author

NoLooseEnds commented Mar 10, 2019

Ok. But it has to be something special with Flood, since it semi-works (ie. loads up the login/setup part, but hangs in the loading screen after entering the credentials). And every other container (including rutorrent, that connects to the same socket) works.

@stigger
Copy link

stigger commented Mar 10, 2019

I also experience exactly the same symptoms. In my case it's not a docker image, just self-installed flood with nginx, nginx has proxy_pass http://127.0.0.1:3000;. Works fine when accessing flood directly, hangs when accessing through nginx.

@NoLooseEnds
Copy link
Author

Glad I'm not alone.

Could it be a "bug" with Flood? It has to be something with the login process that Flood does differently than most other? Since I have a few other services that requires login that works fine.

Maybe it should be reopened and have the bug tag after all @noraj?

@noraj
Copy link
Contributor

noraj commented Mar 11, 2019

Did you tried to add proxy_http_version and other headers I used in my example with nginx?

PS : I'm not a dev, only a member helping with issue on its own spare time.

@stigger
Copy link

stigger commented Mar 11, 2019

I didn't, I followed this guide, which mentioned only the proxy_pass: https://github.com/jfurrow/flood/wiki/Using-Flood-behind-a-reverse-proxy

Will try later today.

@stigger
Copy link

stigger commented Mar 11, 2019

I added additional settings and that did not help. I looked in the dev console which request is actually hanging, and it turns out that it's /api/activity-stream?historySnapshot=fiveMin: it's returned quite fast when accessing directly, but never finishes and eventually times out when accessing via nginx. In my case the response is ~10M in size.

@NoLooseEnds
Copy link
Author

Looks like that is the same issue I face – sort of. Mine is not 10M in size, but it gives no response.

Screenshot 2019-03-12 at 01 18 43

Screenshot 2019-03-12 at 01 19 17

Screenshot 2019-03-12 at 01 19 44

Screenshot 2019-03-12 at 01 19 53

@noraj
Copy link
Contributor

noraj commented Mar 16, 2019

I re-installed rTorrent + Flood recently from git. Working behind nginx reverse proxy. The steps I followed are described here. And finally it works perfectly. Nearly every user of flood make it work behind a reverse proxy (Nginx, Apache httpd, etc.).
I'm sorry @stigger but the current version of flood works behind a reverse proxy, if it is not working it may be because you have an external program interfering, you misconfigured the setup, or something else but not because of flood.

@noraj
Copy link
Contributor

noraj commented Mar 16, 2019

PS : As you can read I'm using more instructions that only proxy_pass and a lot of tutorials are using those blocks too.
Maybe it was shinji257 that wrongly simplified the wiki page https://github.com/jfurrow/flood/wiki/Using-Flood-behind-a-reverse-proxy/_history

@noraj
Copy link
Contributor

noraj commented Mar 16, 2019

@Zyrophr As you seem to use a nested route, have you put baseURI: '/flood' in your config.js ?

For support there is no better place than the Discord troubleshooting channel.

--- PS ---

I'm not a dev of Flood, only a member helping with issues on his free time.

The only dev is @jfurrow, but he is not active anymore. @Zyrophr if you care about Flood take a look at #712 and #672. The actual project is slowly dying without active developers.

@noraj noraj added the question label Mar 16, 2019
@noraj noraj reopened this Mar 16, 2019
@andsens
Copy link

andsens commented May 1, 2019

@Zyrophr, add a / to the end of your location /flood { like so location /flood/ {, do the same for your proxy_pass like so proxy_pass http://127.0.0.1:3000/, and then kill the rest it's not needed.

location /flood/ {
    proxy_pass http://127.0.0.1:3000/;
}

In order to support easy access without the trailing slash, add this below:

location /flood {
    rewrite ^/flood$ /flood/ permanent;
}

My case was a little more complicated, I actually had two reverse-proxy chained. One front-facing with SSL and another that simply spliced connections to rtorrent RPC and flood on that VM. Apparently keep-alive don't work on nginx if you proxy twice.
My tests:

Front facing nginx -> VM nginx -> flood: activity-stream is dead
VM nginx -> flood: works
Front facing nginx -> flood: works

So with regards to keep-alive settings on a reverse proxy, logic would dictate both of the nginx setups are configured correctly. I have no clue whatsoever why chaining two reverse proxies doesn't work.

@0xAF
Copy link

0xAF commented May 24, 2019

I had this problem too. After the login screen Flood hangs and do not show the torrents screen.
I just updated the repo (git pull) and ran npm run build (which actually fixed the problem).
I guess I just had to rebuild it, so my browser gets up-to-date JS code.

@billimek
Copy link

billimek commented Jun 2, 2019

Has anyone successfully found a traefik configuration that will work with flood? Using traefik for about 30 other applications and don't experience this type of behavior.

I have no problem hitting flood directly but when proxying via traefik, it experiences the issue with not rending anything after the initial flood login screen. This is with the default / path and no custom subdomain.

@andsens
Copy link

andsens commented Jun 2, 2019

@billimek, I am almost certain that the hanging has something to do with the TCP connection not staying open via keep-alive so that flood can push the activity-stream data. I would suggest figuring out what exactly is terminating your TCP connection.

@chortya
Copy link

chortya commented Jun 2, 2019

In my case the issue was with the adblocker (Adguard). I figured this out because Flood worked from my mobile but not laptop Chrome. Flood IP was whitelisted but Adguard probably altered TCP flow anyways.

@DotEfekts
Copy link

I'm having the same issue and as far as I can tell @andsens is right about keep-alive connections being disrupted but they don't seem to be dropped altogether, just delayed for some minutes, which leads me to think Traefik is buffering these responses for some reason. Whether this is a Flood specific thing or a general Traefik thing I'm not sure.

@0xAF
Copy link

0xAF commented Jun 5, 2019

My problem was present while running nginx, but actually even opening flood directly (on it's port), there was still problem. So at least for me, the problem was in flood and rebuilding everything with npm fixed it.
I've seen the same problem before, but after reloading the page it was working, but not this time. Perhaps some system update broke something on which flood relied...

@andsens
Copy link

andsens commented Jun 5, 2019

@DotEfekts I figured it out!
On nginx when chaining 2 nginx reverse-proxies I can get keep-alives working by disabling proxy buffering on the front-facing proxy. It has no effect when I turn it off on the proxy right before flood.

proxy_pass http://flood;                                                                                                                 
proxy_buffering off;

I work with traefik myself, though not in that context. There seem to be some buffering related configs in traefik, but the documentation implies that buffering is something you turn on. So I'm not sure whether the underlying issue is the same.

@billimek
Copy link

billimek commented Jun 5, 2019

I found a traefik configuration which seems to allow this to work!

Based on this issue, I looked at the traefik compression documentation and disabled compression for my traefik instance for the https entrypoint via,

[entryPoints]
  [entryPoints.https]
  address = ":443"
  compress = false

And the flood UI will now properly load after the auth screen.

No idea what the ramifications are for other things by globally disabling compression in traefik, but it does 'resolve' the above issue in my case, at least.

@andsens
Copy link

andsens commented Jun 5, 2019

@billimek that makes perfect sense wrt buffering. You can't compress without at least buffering some of the data, which is what seems to kill keep-alives!

@DotEfekts
Copy link

@andsens I've got nginx at the front going to Traefik in an Linux container and that seems to have done it for me, thanks!

@crimist
Copy link

crimist commented Jul 12, 2019

I'm running Flood on WSL (Windows Subsystem for Linux) and I'm able to reproduce this issue. No proxy server just listening on 127.0.0.1:3000

@ghost
Copy link

ghost commented Sep 8, 2019

Seeing this on a FreeBSD system as well, using nginx as reverse-proxy and accessing over a Wireguard tunnel. Tried with chromium and firefox, same issue in both.

@nitnelave
Copy link

Hey everyone! I just went through the whole dance of figuring out how to solve this issue. TL;DR: it's because of nginx buffering, and I added a solution in the wiki here: https://github.com/Flood-UI/flood/wiki/Using-Flood-behind-a-reverse-proxy#disable-buffering

The /api/activity-stream page is, well, a stream. When Nginx tries to serve that, it will attempt to read the entire response before returning it to the client, which means that it will hang forever and never respond. Killing rTorrent "solves" the issue by ending the stream, thus sending all the info to the client. A better solution is to disable nginx buffering for that location. I added instructions for that in the docs, and tested it on my setup.

Hope it helps!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants