NetTalk Central

Author Topic: Application holding 2 ports  (Read 4289 times)

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Application holding 2 ports
« on: August 15, 2015, 01:08:03 AM »
From Nettalk 4 days I have controlled the port I am using for my application via a table which allows me to have the same application using different ports without having to change the Listen On Port number in The Nettalk object and then having to recompile for different users.
I do it my placing this code in the WindowManager Init after Open Files
WEBCTL:WebControlID = 'aaaaaaaaaaaaaaaa'
IF ACCESS:WebControl.FETCH(WEBCTL:KEY_WebControlID)
    WebControlFound = FALSE
ELSE
    WebControlFound = TRUE
    CompanyName = CLIP(WEBCTL:CompanyName)
    HomeWebSiteAddress = CLIP(WEBCTL:HomeWebSiteAddress)
    IF HomeWebSiteAddress = ''
        HomeWebSiteAddress = 'web'
    END
    HTTPPort = WEBCTL:HTTPPort
    IF HTTPPort = 0
        HTTPPort = 80
    END
END
TaskbarDescription='[' & HTTPPort & '] ' & CLIP(CompanyName) & ' Location: ' & CLIP(HomeWebSiteAddress)
ACCESS:WebControl.Close()
ACCESS:WebLogin.Close()

For my development I normally use 8088 so that it doesn't clash with the 88 used by Capesoft in their examples although in the default settings in the Nettalk object I do have 88.

Previously I have never had an issue with this; the port is set to the port I specify in the code.
Lately ( going back quite a few versions of Nettalk8) I have noticed that Port88 was being blocked.
Only recently did I realise that this happened when I was running my app on 8088. I could access my application on 8088 as normal but I couldn't run a capesoft app on 88 at the same time.
I used netstat -ano in cmd I found that both port 88 and port 8088 were being listened to by the same pid, my exe.
Has there been a change that I didn't see that can cause this, and if so how should I change my app to allow me to continue without holding the default port.
Even though the app is supposedly listening on port88 I can't access it on that port.
« Last Edit: August 15, 2015, 02:55:05 AM by terryd »
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11247
    • View Profile
Re: Application holding 2 ports
« Reply #1 on: August 16, 2015, 10:18:31 PM »
Hi Terry -

there's been no change here, and there's nothing "hard coded" to port 88.
so I'm guessing you have a second Server object somewhere in your app - maybe on the same WebServer window.

cheers
Bruce

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Application holding 2 ports
« Reply #2 on: August 17, 2015, 12:07:17 AM »
Bruce I don't there is a second server object.
Attached are 2 command line images (using netstat -ano)
I reverted to NT847 compiled and started the app and ran netstat. There is only 1 occurrence  listening on the port 8088 (PID1904)
Installed 859 compiled and started the app and ran netstat There are now 2 occurrences listening for PID7008 one on Port 88 and one on Port 8088
Same app no changes

[attachment deleted by admin]
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Application holding 2 ports- Resolved
« Reply #3 on: August 17, 2015, 01:34:05 AM »
After discussion with Bruce
In the Override Default Server Settings embed of the WebServer I had code that closed the webserver allocated my new port and then reopened the webserver
What appears to happen in alater versions of Nettalk (not in 847 backwards)  is the the webserver doesn't close the connection, the template value for the port is retained and the new port is also used.
Solution
Bruce suggested I set the value in the template to a variable HttpPort and then removed the code which stopped and restarted the webserver
So the HttpPort value is set in the code I showed previously and that is used by the template.

Thanks Bruce
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186