Page 1 of 1

Shareaza switches to random port mode on connection loss

PostPosted: 07 Apr 2013 19:12
by pluriel
My internet connection drops out briefly from time to time. I've noticed that Shareaza automatically enters random UPnP port mode after about a minute when this happens and registers new (random) ports with the router (random gets checked in Internet->Connection settings page). Also, Shareaza deletes the newly registered random ports from the router's port map list when closing the connection, but the previously registered ports remain (which means I have to remove them manually).

I would like Shareaza to continue using the originally registered ports and not enable random ports when the internet connection is lost. I have tried changing Connection.DetectConnectionLoss and Connection.DetectConnectionReset, and combinations thereof in the Advanced settings page to no avail.

Can anyone help me fix this odd behavior?

Re: Shareaza switches to random port mode on connection loss

PostPosted: 08 Apr 2013 11:00
by pluriel
On closer inspection it appears that after the internet connection is lost (but before it's re-established), Shareaza sends a "port open" request to the router using the same port number it had requested the first time. These ports being already assigned, the router presumably sends a "port not available" reply (or something to that effect) to Shareaza, to which Shareaza responds by entering random port mode and re-requesting ports using the new random port number. Shareaza "forgets about" the original ports thereafter, having replaced them with the new random ports.

Since Shareaza cannot know the reason why the internet connection was lost; e.g. whether or not the router was turned off, or there was a line dropout, ppp disconnect, etc., and hence cannot tell whether or not the prevously assigned ports are still active (i.e. on the router's UPnP port map list), there should be a fix to this which covers all cases. I suppose a solution would be for Shareaza to:

a) Wait until the internet connection is re-established,
b) Close the previously requested ports (i.e. send a "port close" command), and
c) Send a new "port open" command using the original port number

after the internet connection is lost, without entering random port mode. An alternative might be to change b) to:

b) Check if the previously assigned ports are still active (i.e. send a "port list" command), and skip c) if they are.

Any thoughts about this are appreciated.

PS I'm talking here about the current 32-bit release of Shareaza (v. 2.6.0.0)

Re: Shareaza switches to random port mode on connection loss

PostPosted: 19 Apr 2013 11:46
by old_death
I've moved this to the development discussion...

Re: Shareaza switches to random port mode on connection loss

PostPosted: 19 Apr 2013 15:04
by pluriel
As an additional thought, if Shareaza were to check the UPnP port status (or just close/open ports) whenever it begins its connection sequence, this would also prevent it from re-requesting ports after a PC/program crash.

:geek:

Re: Shareaza switches to random port mode on connection loss

PostPosted: 22 May 2015 20:42
by queuesclimber
Like you know, I am a trunkrunner on low level. VS2013 Update 3
Running @release, SSE2, debug (.pdb) and my settings hardcoded.
And it happens since around 8 month.
This is a Bug.

This is what I have found out.
When having a standrad-crash ( like in albumfolder.cpp in bugreportwindow ) everything is fine.
But when getting [Access Violation at (memory:adress) in shareaza.exe ] and memory is shuffled to somewhat,
sometimes it happends the RandomPortBug.

Mmmhhh, InPort is stored in registry. For crosschecking ( in the debugs ) cant you store a .cfg-7z somewhere ?
LOL, it's dinosaur-technology. (But when restarting and getting lowID, always port has changed)

Re: Shareaza switches to random port mode on connection loss

PostPosted: 27 Feb 2016 14:50
by siavoshkc
I conform that Shareaza enables random port by itself when starting network core while UPnP function is enabled. I don't know if it happens when UPnP is disabled or not.