Opened 13 years ago

Closed 13 years ago

#1993 closed Enhancement (fixed)

Check if UPNP port is still open

Reported by: KyleK Owned by: charles
Priority: Normal Milestone: 1.60
Component: libtransmission Version: 1.52
Severity: Normal Keywords:
Cc:

Description

I'm using the latest trunk version of Transmission, the daemon to be precise. I have enabled automatic port mapping (via UPNP) as well as random port at startup. All that works well.

I discovered lately that after some (undetermined) amount of time the port mapping disappears from my router. I'm 90% sure that this is not really Transmissions fault, but rather the routers.

Still, since waiting for a firmware update could take a while, I'd like to suggest an enhancement: Transmission could check in intervals (maybe once every 30 minutes or so) if the previously requested port is still open. If yes, nothing has to be done. Otherwise, remap it. This is how uTorrent does it to "fix" badly behaving routers.

Attachments (2)

check_upnp_v1.patch (2.3 KB) - added by KyleK 13 years ago.
portcheck_v2.patch (3.9 KB) - added by KyleK 13 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 13 years ago by livings124

Transmission uses miniupnp (http://miniupnp.tuxfamily.org/) for upnp. Could you report this upstream to them?

comment:2 Changed 13 years ago by KyleK

Well, I sure can, but I'm not sure if this falls into miniupnp's field of functionality. It only provides an API to the UPNP specification after all. To check if the port is open in intervals would require it to use some sort of timer, which I doubt is implemented there.

comment:3 Changed 13 years ago by livings124

miniupnp is meant to open the port. If the port isn't staying open, why would that be Transmission's responsibility and not the port forwarding library's. As you said, the problem isn't caused by Transmission.

comment:4 Changed 13 years ago by charles

livings124: I think KyleK is correct here. We need to periodically re-subscribe to the port to keep it forwarded.

comment:5 Changed 13 years ago by livings124

Alright, I stand corrected. But why is that Transmission's responsibility and not miniupnp's?

comment:6 Changed 13 years ago by KyleK

Because miniupnp only provides the functionality to open/close a port (and query general information from a UPNP router). It does not provide functionality to keep the port open.

Basically, the required functionality is a workaround for "bad" routers that close a port for no reason whatsoever (I think my router does it after there has been no data transmission on that port for an extended amount of time).

It shouldn't be too hard to do, I'll investigate.

comment:7 Changed 13 years ago by charles

KyleK: due to some disk problems, transmissionbt.com had to revert to yesterday's backup. This means that we've lost your patch for this ticket, as well as your ticket and patch for the IPv6 crash. Could you resubmit these?

comment:8 Changed 13 years ago by KyleK

Good thing I didn't delete the patch files yet. Normally this tracker is my backup :D

Anyways, here is v1 of the patch again. I believe it is not too pretty, and an alternative would be to add a second timer to the tr_shared object that just deals with the checking of the port. I'm not sure of the memory/performance impact of that approach though.

Let me know what you think.

Changed 13 years ago by KyleK

comment:9 Changed 13 years ago by charles

Timers are very inexpensive, so that's probably the right thing to use here.

comment:10 Changed 13 years ago by KyleK

Great. I'll revise my patch tomorrow :)

Changed 13 years ago by KyleK

comment:11 Changed 13 years ago by KyleK

Ok, here's v2 of the proposed patch. This time I use a second timer to fire up the port check at a 20 minute interval. This resolution seems much cleaner than the previous one :)

On a side note, I found out why my router loses these mappings now and then: For some reason it does a hard reboot once in a while, and that apparently clears all port mappings :/ (and logs)

comment:12 Changed 13 years ago by charles

  • Milestone changed from None Set to 1.60
  • Status changed from new to assigned
  • Version changed from 1.52+ to 1.52

portcheck_v2.patch applied to trunk for 1.60 in r8271.

comment:13 Changed 13 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.