irigsoft Posted August 11, 2021 Share Posted August 11, 2021 Hello, I'm trying to protect the launch of multiple StandAlone applications on a single server port. The Case: 1. Start StandAlone server with uniServerModule with Port = 8078. 2. Try to start application again (but it crash with message "port is in use", that is OK) I want to check when application start if port is opened and show message , after that close application. I use this in uniServerModule.BeforeInit function PortAvailable (Port:STring):boolean; var svr : TTCPBlockSocket; begin svr := TTCPBlockSocket.Create; try svr.Bind('0.0.0.0',Port); svr.Listen; result := svr.LastError = 0; Svr.CloseSocket; finally svr.Free; end; end; begin if (not PortAvailable (SistemSettingsList.Values ['WebPort'])) then begin UniServerModule.Terminated := True; exit; end; end; Procedure works and the application displays a message and closes, but first one Application starts showing errors when accessing local resources such as uniImage.LoadFromFile, etc. After starting the second application, the first one no longer works properly. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 11, 2021 Share Posted August 11, 2021 Hello irigSoft, Standalone EXE is for testing Uniapplication. Why did'nt you deploy it as Hyperserver (Service or iis) ? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 11, 2021 Author Share Posted August 11, 2021 7 minutes ago, Abaksoft said: Hello irigSoft, Standalone EXE is for testing Uniapplication. Why did'nt you deploy it as Hyperserver (Service or iis) ? At this moment i make only StandAlone (I have some troubles to Service and IIS). But already work on production development and must make some user friendly procedures. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 11, 2021 Author Share Posted August 11, 2021 15 minutes ago, Abaksoft said: Standalone EXE is for testing Uniapplication. Can you tell me what restrictions will be expected from StandAlone (I know all the security, etc., I will have to do myself, but what else) ? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 11, 2021 Share Posted August 11, 2021 1 hour ago, irigsoft said: Can you tell me what restrictions will be expected from StandAlone ? Ho...i have'nt a great knowledge for that. Except from the doc : "Standalone Server is a good option for debugging your application or when you need a web server when server availability is not very important."...... "For serious deployment you must choose either ISAPI Module or Windows Service deployment options." http://www.unigui.com/doc/online_help/standalone_server.htm Maybe the big advantage in a standalone application is to track memory leaks and evaluate memory consumption. I saw your topics with your concern for security. You pointed on sensitive points and i thank you for that. Regards. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 11, 2021 Share Posted August 11, 2021 2 hours ago, irigsoft said: I have some troubles to Service and IIS What kind of troubles ? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 12, 2021 Author Share Posted August 12, 2021 6 hours ago, Abaksoft said: What kind of troubles ? Insignificant. The project had to start due to an existing client and this required working with the first possible one. I didn't want to create several projects just to be able to test with one and the other to work (Service or ISAPI). Of course, now there is a need to create a Service, but the project has grown a lot and it is difficult for me to transfer it to a new one. For example, I tried to create a service module using directives to create everything in one (StandAlone and Service), but I understand that I have to copy everything from uniServerModule to UniServiceModule. I may be wrong. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 12, 2021 Share Posted August 12, 2021 2 hours ago, irigsoft said: but I understand that I have to copy everything from uniServerModule to UniServiceModule. No, To use your application as Service, you have'nt to copy everything from UniServerModule to UniServiceModule. just add an empty UniServiceModule and start your service. Really, running your standalone EXE as Service, is very easy to deploy. Just follow step by step the doc. http://www.unigui.com/doc/online_help/index.html?windows_service.htm Besides this, it's recommended to use Service on HyperServer. http://www.unigui.com/doc/online_help/index.html?hyperserver-windows-service-mo.htm You can also see my easy installer : http://forums.unigui.com/index.php?/topic/14896-a-windows-service-installer/&do=findComment&comment=81112 you can see also : http://forums.unigui.com/index.php?/topic/11893-hyperserver-isapi-module-or-windows-service/&do=findComment&comment=94353 Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 12, 2021 Author Share Posted August 12, 2021 3 minutes ago, Abaksoft said: To use your application as Service, you have'nt to copy everything from UniServerModule to UniServiceModule. just add an empty UniServiceModule and start your service. Super and Thank You. I will try to compile Service, but if I have one service starting on port 8078 and another on port 8079 How to Install this two Services, with different names or must use IIS ? Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted August 12, 2021 Share Posted August 12, 2021 10 minutes ago, irigsoft said: ut if I have one service starting on port 8078 and another on port 8079 How to Install this two Services, with different names or must use IIS ? IIS is an other story. Let's stay and focus on service mode. Each uniApplication will have its own Port. Example, on the same PC (server) App1 : 192.168.1.11:8079 App2 : 192.168.1.11:8080 App3 : 192.168.1.11:8081 The port information is edited on : UniServerModule and on the cfg file (if you will go will hyperserver). After playing with that (this will take you a hour), you can go (and it's recommanded) with hyperserver. The port here requires an other "sub port". it's called Start_port. You have to config this on the hyperserver cfg file, to ovoid overlap with nodes. http://forums.unigui.com/index.php?/topic/14556-one-server-two-applications-one-calls-the-other/ Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 12, 2021 Author Share Posted August 12, 2021 8 minutes ago, Abaksoft said: IIS is an other story. Let's stay and focus on service mode. Each uniApplication will have its own Port. Example, on the same PC (server) App1 : 192.168.1.11:8079 App2 : 192.168.1.11:8080 App3 : 192.168.1.11:8081 The port information is edited on : UniServerModule and on the cfg file (if you will go will hyperserver). After playing with that (this will take you a hour), you can go (and it's recommanded) with hyperserver. The port here requires an other "sub port". it's called Start_port. You have to config this on the hyperserver cfg file, to ovoid overlap with nodes. http://forums.unigui.com/index.php?/topic/14556-one-server-two-applications-one-calls-the-other/ Thank You. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 12, 2021 Author Share Posted August 12, 2021 But does anyone know "How to check if uniServerModule.Port is already in use" I found solution for me with mutex, but If uniApplication have own method, will be good to I know that. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 18, 2021 Author Share Posted August 18, 2021 Hello @Sherzod, Can You tell me Is it possible to check if Port is in use when project starts. Standalone or Service. You must to know: I set Port on BeforeInit from SettingsFile Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 18, 2021 Share Posted August 18, 2021 Hello @irigsoft, On 8/12/2021 at 2:17 PM, irigsoft said: I found solution for me with mutex You already seem to have a solution? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted August 18, 2021 Author Share Posted August 18, 2021 58 minutes ago, Sherzod said: Hello @irigsoft, You already seem to have a solution? Yes, I created mutex and it works for me, but are there any features integrated into uniApplication ? Quote Link to comment Share on other sites More sharing options...
Tokay Posted August 21, 2021 Share Posted August 21, 2021 Unfortunately current UniGUI version cannot process correctly used ports. It just crash, and we if I understand properly could not intercept exception to do logs what is happens. It very inconvenient behaviour. In our 'main' web app we get maximum info to users what is happens while app started: info that port is already used and (under windows) wich app is used the port. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.