Recent

Author Topic: [SOLVED] How to open UPnP port with synapse  (Read 13446 times)

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #75 on: November 21, 2023, 06:13:57 pm »
$ ./upnpc-shared -l
That's on Linux.
Does it work on Windows?

Key-Real

  • Sr. Member
  • ****
  • Posts: 395
Re: [SOLVED] How to open UPnP port with synapse
« Reply #76 on: November 21, 2023, 06:14:51 pm »
its on Windows in mingw64 shell

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #77 on: November 21, 2023, 06:35:34 pm »
its on Windows in mingw64 shell
Ai. That's some piece of missing information.
Are you also running the Windows version on mingw64?

Why not just compile on plain Windows with an .exe?

I don't have mingw64 and didn't test that.

Key-Real

  • Sr. Member
  • ****
  • Posts: 395
Re: [SOLVED] How to open UPnP port with synapse
« Reply #78 on: November 21, 2023, 06:38:52 pm »
Microsoft Windows [Version 10.0.19045.3570]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\Users\Key-Real>cd C:\Users\Key-Real\Downloads\win32-miniupnpc-2.1

C:\Users\Key-Real\Downloads\win32-miniupnpc-2.1>upnpc-shared.exe -l
upnpc : miniupnpc library test client, version 2.1.
 (c) 2005-2018 Thomas Bernard.
Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
for more information.
List of UPNP devices found on the network :
 desc: http://192.168.0.1:49153/IGDdevicedesc_brlan0.xml
 st: urn:schemas-upnp-org:device:InternetGatewayDevice:1

Found valid IGD : http://192.168.0.1:49153/upnp/control/WANIPConnection0
Local LAN ip address : 192.168.0.5
Connection Type : IP_Routed
Status : Connected, uptime=0s, LastConnectionError : ERROR_NONE
MaxBitRateDown : 100000000 bps (100.0 Mbps)   MaxBitRateUp 100000000 bps (100.0 Mbps)
ExternalIPAddress = 31.18.189.13
 i protocol exPort->inAddr:inPort description remoteHost leaseTime
GetGenericPortMappingEntry() returned 713 (SpecifiedArrayIndexInvalid)

C:\Users\Key-Real\Downloads\win32-miniupnpc-2.1>


its on windows cmd.exe

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #79 on: November 21, 2023, 06:43:07 pm »
C:\Users\Key-Real>cd C:\Users\Key-Real\Downloads\win32-miniupnpc-2.1
Ok. Then it should also work in FPC with Synapse.

Did you use 0.0.0.0 as ip for calling Create?

You could try the direct ip of the router to see if it makes a difference.

Key-Real

  • Sr. Member
  • ****
  • Posts: 395
Re: [SOLVED] How to open UPnP port with synapse
« Reply #80 on: November 21, 2023, 06:46:28 pm »
no effect

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #81 on: November 21, 2023, 06:52:00 pm »
no effect
Then I don't know why it's not working.

You could try to disable the firewall temporarily.
(Just to rule out certain things)

Key-Real

  • Sr. Member
  • ****
  • Posts: 395
Re: [SOLVED] How to open UPnP port with synapse
« Reply #82 on: November 21, 2023, 06:59:19 pm »
no effect :(

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #83 on: November 21, 2023, 07:04:23 pm »
no effect :(
I'm puzzled.

How long does it take before the program ends with no result?

Should at least take a few seconds.

You could change the repeat  Cnt > 1 to Cnt > 4 or more in the Create.

Key-Real

  • Sr. Member
  • ****
  • Posts: 395
Re: [SOLVED] How to open UPnP port with synapse
« Reply #84 on: November 21, 2023, 07:08:08 pm »
a second

the change has no effect

have to go for a hour, have to by me something to eat...

balazsszekely

  • Guest
Re: [SOLVED] How to open UPnP port with synapse
« Reply #85 on: November 21, 2023, 07:18:35 pm »
@rvk

Changing the following line in the TUPnP constructor, solves the issue(at least it did for me):
Code: Pascal  [Select][+][-]
  1.    //...
  2.    DestAddr.sin_family := AF_INET;
  3.    DestAddr.sin_port := htons(1900);
  4.    DestAddr.sin_addr := StrToNetAddr('255.255.255.255'); //<--this one
  5.    DestAddr.sin_addr := StrToNetAddr(RouterIP); //<--to this
  6.    fpSendTo(Socket, @S[1], Length(S), 0, @DestAddr, SizeOf(DestAddr));    
  7.   //..  

Now I got a response, later the following line fails:
Code: Pascal  [Select][+][-]
  1. Service := GetStringBetweenAndStrip(S, '<service>', '</service>');
There are no services at all, but maybe that's just my router.

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #86 on: November 21, 2023, 07:20:00 pm »
a second
Should be a least 3 seconds.

With a second there is something wrong with communication/sockets.

I did change the broadcast from 255.255.255.255 to the router IP if it's provided (it was always 255.255.255.255).
So you can do the test for direct IP again.

But "a second" is too soon for "nothing found".


Changing the following line in the TUPnP constructor, solves the issue(at least it did for me):
Yeah, I just found that. That's for passing direct IP of the router.
But 255.255.255.255 broadcast should have worked too.

Now I got a response, later the following line fails:
Code: Pascal  [Select][+][-]
  1. Service := GetStringBetweenAndStrip(S, '<service>', '</service>');
There are no services at all, but maybe that's just my router.
Maybe uPNP not enabled  :D

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #87 on: November 21, 2023, 07:25:32 pm »
Maybe the 255.255.255.255 broadcast doesn't work with all Windows configurations.

Maybe a routing problem with multiple network interfaces.

https://serverfault.com/questions/72112/how-to-alter-the-global-broadcast-address-255-255-255-255-behavior-on-windows

Direct router IP with Create should work now in the latest version
https://github.com/rvk01/upnp

@Key-Real: It should also be possible to use 192.168.0.255 (so last number 255) for broadcast.

BTW. It would be interesting to see your "route print" output. Especially the 255.255.255.255 addresses at the bottom.
The interface with the lowest metric will get the broadcast.
For me that's my internal IP for my internet access.

Code: Text  [Select][+][-]
  1.   255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  2.   255.255.255.255  255.255.255.255         On-link     192.168.224.1   5256
  3.   255.255.255.255  255.255.255.255         On-link        172.17.0.1   5256
  4.   255.255.255.255  255.255.255.255         On-link      192.168.2.11    281
  5.   255.255.255.255  255.255.255.255         On-link     192.168.208.1   5256

Optimum would be to try to send a broadcast to 255.255.255.255 over ALL interfaces.
I read that Windows XP did that but Windows 7+ not.
« Last Edit: November 21, 2023, 07:34:15 pm by rvk »

balazsszekely

  • Guest
Re: [SOLVED] How to open UPnP port with synapse
« Reply #88 on: November 21, 2023, 07:34:05 pm »
@rvk
Quote
Maybe uPNP not enabled  :D
It is, I double checked. I also ran upnpc-shared.exe -l which confirms that everything is OK.
After reading you last post, I did try 192.168.0.255 and it works fine(external IP edited) :)
Quote
UPnP device is available at http://192.168.0.1:1900/ipc

Internal IP: 192.168.79.1
External IP: X.X.X.X
Status: Connected
Last error: ERROR_NONE
Uptime router: 0 days 0 hours 0 minutes and 0 seconds

SetPortMapping OK
Portmappings:
0 TCP 8000->192.168.79.1:8081  0 s

Check port. Press Enter to delete and terminate

Surprisingly 192.168.0.1, the router IP address is not working.

rvk

  • Hero Member
  • *****
  • Posts: 6922
Re: [SOLVED] How to open UPnP port with synapse
« Reply #89 on: November 21, 2023, 07:39:26 pm »
Quote
Maybe uPNP not enabled  :D
It is, I double checked. I also ran upnpc-shared.exe -l which confirms that everything is fine with UPnP.
After reading you last post, I did try 192.168.1.255 and it works fine(external IP edited) :)
(..)
Surprisingly 192.168.0.1, the router IP address is not working.
Maybe the first M-SEARCH result from the 192.168.0.1 doesn't contain the services.
That's why the Cnt counter is reset when LOCATION is found until there is one where services is included.

Did your first M-SEARCH result from 192.168.0.1 contain a LOCATION header?

If it does not, and there are more than 1 such devices (like multimedia devices) the scan could end prematurely.

I might need to rethink the SCAN function. It was designed to not wait too long for a result if there is no uPnp device on the network.
But that's a balancing act (for waiting until you DO need to find one)  :D

If there are M-SEARCH messages without a LOCATION header I just need to check if Message <> '' and then reset the Cnt to 0 for that.
« Last Edit: November 21, 2023, 07:42:03 pm by rvk »

 

TinyPortal © 2005-2018