arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.22k stars 992 forks source link

lsd_error Local Service Discovery startup error [::1]: Can't assign requested address #7287

Closed smokracek closed 1 year ago

smokracek commented 1 year ago

Please provide the following information

libtorrent version (or branch): 2.0.8

platform/architecture: MacOS Ventura, x86

compiler and compiler version: Clang 14.0.0

please describe what symptom you see, what you would expect to see instead and how to reproduce it.

I'm doing a fairly simple setup where I add a magnet link to a session and poll for alerts, with the lt::session object is held in a static singleton.

client_session.cpp:

ClientSession::ClientSession() {
        lt::settings_pack settings;
        settings.set_int(
            lt::settings_pack::alert_mask, 
            lt::alert_category::status 
            | lt::alert_category::error
            | lt::alert_category::storage);
        lt::session session_(settings);
    }
void ClientSession::addMagnet(const std::string& magnet_uri) {
        lt::add_torrent_params params = lt::parse_magnet_uri(magnet_uri);
        params.save_path = storage_dir_;
        session_.add_torrent(std::move(params));
    }

alert polling code:

std::vector<std::string> ClientSession::get_alerts() {
        std::vector<lt::alert*> alerts;
        session_.pop_alerts(&alerts);
        std::vector<std::string> ret;
        for (auto alert : alerts) {
            ret.push_back("Alert: " + std::string(alert->what()) + " " + alert->message());
        }
        return ret;
    }

Hopefully this makes sense. Anyhow, I can't seem to initiate a download, and I consistently get the lsd_error Local Service Discovery startup error [::1]: Can't assign requested address error.

I've tried using settings.set_str(lt::settings_pack::listen_interfaces, ...) with multiple IPs and ports, including 127.0.0.1:6881. I've also tried turning on and off my VPN, deleting buildfiles, etc. I'm kind of at a loss and would appreciate some advice. Maybe I'm missing something obvious.

arvidn commented 1 year ago

Anyhow, I can't seem to initiate a download

The call to add_torrent() initiates the download. What is not working as you would expect? There are a number of steps that need to work before you end up with files on disk. There's an (incomplete) trouble shooting guide here: http://libtorrent.org/troubleshooting.html

and I consistently get the lsd_error Local Service Discovery startup error [::1]: Can't assign requested address error.

That's not a fatal error, that just means local service discovery won't work over IPv6.

I've tried using settings.set_str(lt::settings_pack::listen_interfaces, ...) with multiple IPs and ports, including 127.0.0.1:6881. I've also tried turning on and off my VPN, deleting buildfiles, etc.

setting listen_interfaces is an easy way to break downloading. If you do, you should make sure you pay attention to listen_failed_alert and listen_succeeded_alert. If you're using a VPN, you probably want to set it to the VPN address or device name (+ port).

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.