Page 1 of 1

WebUI stop working

Posted: Thu May 07, 2015 8:42 pm
by dimzon
I don't change anything in my Ubuntu 12.04 NAS server. I'm running Deluge 1.3.5 (stick to this version for some reason).
As I discovered web.update_ui AJAX requests stop responding (GTK client works fine). I used primitive debugging (adding log.info invocations into json_api.py).

Code: Select all

    @export
    def update_ui(self, keys, filter_dict):
        """
        Gather the information required for updating the web interface.

        :param keys: the information about the torrents to gather
        :type keys: list
        :param filter_dict: the filters to apply when selecting torrents.
        :type filter_dict: dictionary
        :returns: The torrent and ui information.
        :rtype: dictionary
        """
        d = Deferred()
        ui_info = {
            "connected": client.connected(),
            "torrents": None,
            "filters": None,
            "stats": {
                "max_download": self.core_config.get("max_download_speed"),
                "max_upload": self.core_config.get("max_upload_speed"),
                "max_num_connections": self.core_config.get("max_connections_global")
            }
        }

        if not client.connected():
            d.callback(ui_info)
            return d

        def got_connections(connections):
            log.info("got_connections")
            ui_info["stats"]["num_connections"] = connections

        def got_stats(stats):
            log.info("got_stats")
            ui_info["stats"]["upload_rate"] = stats["payload_upload_rate"]
            ui_info["stats"]["download_rate"] = stats["payload_download_rate"]
            ui_info["stats"]["download_protocol_rate"] = stats["download_rate"] - stats["payload_download_rate"]
            ui_info["stats"]["upload_protocol_rate"] = stats["upload_rate"] - stats["payload_upload_rate"]
            ui_info["stats"]["dht_nodes"] = stats["dht_nodes"]
            ui_info["stats"]["has_incoming_connections"] = stats["has_incoming_connections"]

        def got_filters(filters):
            log.info("got_filters")
            ui_info["filters"] = filters

        def got_free_space(free_space):
            log.info("got_space")
            ui_info["stats"]["free_space"] = free_space

        def got_torrents(torrents):
            log.info("got_torrents")
            ui_info["torrents"] = torrents

        def on_complete(result):
            log.info("on_complete")
            d.callback(ui_info)

        def on_err1(err):
            log.info("err11")
            d.errback(err)

        d1 = component.get("SessionProxy").get_torrents_status(filter_dict, keys)
        d1.addCallback(got_torrents)

        d2 = client.core.get_filter_tree()
        d2.addCallback(got_filters)

        d3 = client.core.get_session_status([
            "payload_download_rate",
            "payload_upload_rate",
            "download_rate",
            "upload_rate",
            "dht_nodes",
            "has_incoming_connections"
        ])
        d3.addCallback(got_stats)

        d4 = client.core.get_num_connections()
        d4.addCallback(got_connections)

        d5 = client.core.get_free_space(self.core_config.get("download_location"))
        d5.addCallback(got_free_space)

        dl = DeferredList([d1, d2, d3, d4, d5], fireOnOneErrback=True, consumeErrors=True)
        dl.addCallback(on_complete)
        dl.addErrback(on_err1)
        return d
Next I simulate ajax request using CURL:

Code: Select all

me@nas:~$ curl 'http://my.nas:25005/json' -H 'Referer: http://my.nas:25005/' -H 'Origin: http://my.nas:25005' -H 'X-Requested-With: XMLHttpRequest' -H 'User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36' -H 'Content-Type: application/json' --data-binary '{"method":"web.update_ui","params":[["queue","name","total_size","state","progress","num_seeds","total_seeds","num_peers","total_peers","download_payload_rate","upload_payload_rate","eta","ratio","distributed_copies","is_auto_managed","time_added","tracker_host","save_path","total_done","total_uploaded","max_download_speed","max_upload_speed","seeds_peers_ratio"],{}],"id":11}' --compressed -v -H 'Cookie: _session_id=080c4b28ca894c2797357cbd00ef554d2197'
* About to connect() to my.nas port 25005 (#0)
*   Trying 127.0.0.1... connected
> POST /json HTTP/1.1
> Host: my.nas:25005
> Accept: */*
> Accept-Encoding: deflate, gzip
> Referer: http://my.nas:25005/
> Origin: http://my.nas:25005
> X-Requested-With: XMLHttpRequest
> User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36
> Content-Type: application/json
> Cookie: _session_id=080c4b28ca894c2797357cbd00ef554d2197
> Content-Length: 378
>
* upload completely sent off: 378out of 378 bytes
As I see in deluge log ONLY got_torrents is complete, rest defers waits forever