gabrielmagno / crab-dlna

A minimal UPnP/DLNA media streamer written in Rust
Other
69 stars 4 forks source link

Device discovery fail to work on my device #16

Open EMUNES opened 1 year ago

EMUNES commented 1 year ago

I have a laptop with Kodi, and a mobile phone with BubbleUPnP, both support DLNA and can find each other inside the local network. And then I run crab_dlna example code as below in the laptop which hosts Kodi:

use crab_dlna::Render;

#[tokio::main]
async fn main() {
    let discover_timeout_secs = 5;
    let renders_discovered = Render::discover(discover_timeout_secs).await.unwrap();
    for render in renders_discovered {
        println!("{}", render);
    }
}

However, the results show none of them. Any idea for this problem? Thanks.

gabrielmagno commented 1 year ago

Hi @EMUNES !

I have an idea why that could be happening.

I believe it might be due to an upstream limitation in rupnp that does not allow us to specify a TTL in the broadcast message. The TTL in this case specifies the number of "device hops" to search for. So in a multi-router/hub network, some devices will not be show.

I have filled a PR to sddp-client to implement this feature, which was recently accepted, but we are still waiting for a similar PR to be accepted in rupnp.

I think it is possible to implement a temporary fix in crab-dlna if I use sddp-client directly and reimplement the discover function. I will try to work on that in the following days.

Meanwhile @EMUNES , could you confirm if your devices are really in a multi-hop-router environment?

EMUNES commented 1 year ago

Thanks for your detailed reply about what's happening. Sorry that I'm not certain about multi-hop-router as I'm not using mesh network under that environment.

gabrielmagno commented 11 months ago

Hi @EMUNES.

I've implemented the workaround that I mentioned and released a new version (v0.2.1) to include the fix.

If the problem in your environment was this, it will probably work.

But I'm afraid the problem might be another thing: broadcast in multiple network interfaces.

Anyhow, would you mind testing it for us?

EMUNES commented 11 months ago

I have tested again with v0.2.1 but it's unable to find dlna device on my mobile, while I can use Kodi on my PC to find the upnp device (my mobile). Maybe there is other issues.

gabrielmagno commented 11 months ago

@EMUNES could you test something for us?

Are you using Linux? If you are, try installing gupnp-tools, and then run this command to see if it is showing the devices:

gssdp-discover -t AVTransport
EMUNES commented 11 months ago

Execuse me that I'm not using linux for now. But if it helps, I'm sure that I can find those upnp devices in the local network using the upnp_client crate.