Jump to content

How to Check if uniServerModule.Port already is in use ?


irigsoft

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...