Appserver Call

atuldalvi

Member
Hi,

We have designed one test appserver on my colleague machine for our learning.
We both have progress installed on our machines.
We designed 2 programs, one is simple client.p which will call .p kept on appserver working directory.
appserver .p program has only simple message "Hi" nothing else.

client .p is like below
Code:
DEFINE VARIABLE sh AS HANDLE NO-UNDO. /* Server handle  */
DEFINE VARIABLE ah AS HANDLE NO-UNDO. /* Asynchronous request handle */
Def var lServer as logical no-undo.

CREATE SERVER sh.
sh:CONNECT("-AppService test -H xx.xx.xx.xx -S 5162").
IF lServer = FALSE THEN
  ASSIGN sh = SESSION:HANDLE.
IF VALID-HANDLE(sh) = FALSE THEN
DO:
  MESSAGE "No server connected.." VIEW-AS ALERT-BOX.
  RETURN ERROR.
END.
RUN AppSrv.p ON SERVER sh .
RETURN.

when we running client.p from my colleague's desktop then its calling that appserver .p program located in wrking directory and printing message "Hi".

but the same client.p when I am running from my machine, its not calling that appserver program located at my colleague machines, getting message appserver .p not found

How do I test this client server architecture environment.

Please help.
 
Last edited by a moderator:

RealHeavyDude

Well-Known Member
Please encode your code in code tags - it makes it much better readable for us.

Furthermore, I don't think this is the code you are running - it does not make any sense to me ...

Nevertheless:
  1. As soon as you execute CREATE SERVER the handle will always be valid - no matter whether it is connected or not. You need to check whether it is connected or not.
  2. The logical variable lServer is never set - therefore it will have the initial value of FALSE.
  3. Therefore you always assign the server handle to the session handle.
Heavy Regards, RealHeavyDude.
 

RealHeavyDude

Well-Known Member
Forgot ( or hit the post button to early - back from vaction, please bear with me ):

As the sh handle is always set to session:handle your client.p procedure is always executed in the client session, regardless which machine you run it on. If the procedure would run on the AppServer you would never see the "Hi" message - it would show up in the log file of AppServer.

Heavy Regards, RealHeavyDude.
 

atuldalvi

Member
Can u guide me then how i can execute code from my machine to call appserver code located on different machine for my testing ?

my actual code

DEFINE VARIABLE sh AS HANDLE NO-UNDO. /* Server handle */
DEFINE VARIABLE ah AS HANDLE NO-UNDO. /* Asynchronous request handle */
Def var lServer as logical no-undo.

CREATE SERVER sh.
lServer = sh:CONNECT("-AppService test -H xx.xx.xx.xx -S 5162").
IF lServer = FALSE THEN
ASSIGN sh = SESSION:HANDLE.

IF VALID-HANDLE(sh) = FALSE THEN
DO:
MESSAGE "No server connected.." VIEW-AS ALERT-BOX.
RETURN ERROR.
END.
RUN AppSrv.p ON SERVER sh.
RETURN.
 
Last edited:

Cringer

ProgressTalk.com Moderator
Staff member
Code:
DEFINE VARIABLE sh AS HANDLE NO-UNDO. /* Server handle */
DEFINE VARIABLE ah AS HANDLE NO-UNDO. /* Asynchronous request handle */
Def var lServer as logical no-undo.

CREATE SERVER sh.
lServer = sh:CONNECT("-AppService test -H xx.xx.xx.xx -S 5162").
message lServer view-as alert-box.
IF lServer = FALSE THEN 
ASSIGN sh = SESSION:HANDLE.

IF VALID-HANDLE(sh) = FALSE THEN 
DO: 
MESSAGE "No server connected.." VIEW-AS ALERT-BOX. 
RETURN ERROR. 
END.
RUN AppSrv.p ON SERVER sh.
RETURN.

That's a good start. Then you need to actually pay attention to what RHD is suggesting. It might be a good idea to read the documentation too.
 

RealHeavyDude

Well-Known Member
You only need to set up the PROPATH on the AppServer. Basically you can set the PROPATH in many different places. But, the best place for the AppServer PROPATH is the PROPATH property of the AppServer definition in the ubroker.properties file. Personally I would not recommend to set the PROPATH for the AppServer in any other way.

If you want to be able to run the program with and without AppServer ( setting the server handle to the session handle ) then you need to configure the PROPATH for the client too. Usually this only makes senes if you have runtime installations which use an AppServer and some which don't use an AppSever. That way you don't need to ship different versions of applications for AppServer and without.

Furthermore you should check the CONNECTED() method of the server handle in order to determine whether it is connected or not. Checking the validity of the server handle is not sufficient ( see my previous post ).

Last, but not least, you should prevent memory leaks by either deleting the handle based object accordingly ( DELETE OBJECT ... ) or use an unnamed widget pool that is scoped to your procedure.

Heavy Regards, RealHeavyDude.
 

atuldalvi

Member
Thank u all. Now I am able to call the appserver program located on different machine from another machine. As suggesed by RealHeavyDude, I have modified PROPATH property of the AppServer definition.
 
Top