Handling AgiServer

Hi, I have a machine problem in our school regards to Asterisk. I’m using AsteriskJava to interface with my AsteriskNow. I think everything’s working fine, except with integrating Manager and the Default Server. What I want to do is login manager -> start server -> do the originating call -> shutdown the server -> logoff. However, when I login the manager before the startup, AsteriskNow cannot find the AgiServer. When I startup first, It cannot continue to login and do the call. I tried to put AgiServer in the AgiServerThread but same things happen. Is there any proper approach for this? BTW, ports are managed by checking if the port exists and increment one. I don’t know if this is good. Does Asterisk ports itself to 4573 only unless you define a property.