Skip to main content

Summary
Any Orbix server can be configured to listen on a fixed port range. Restricting this port range can force a server to always listen on the same port. Note the behaviour between Java and C is not identical.


Environment
Orbix 6.3
All Supported platforms


Question/Problem Description
Can I run an Orbix server on a fixed port without using the well known addressing policy?


Resolution
An Orbix server's listen port range can be configured using:

policies:iiop:server_address_mode_policy:port_range="5000:5001";


If we start a C server that passes its arguments to the ORB_init():
C:\\apps\\orbix6.3.6x32\\asp\\6.3\\demos\\corba\\orb\\simple_fixed_port\\cxx_server>server -ORBevent_log:filters IT_ATLI2_IP=* -ORBpolicies:iiop:server_address_mode_policy:port_range 5000:5001 -ORBplugins:iiop:ip:reuse_addr false


we can observe this behaviour:
Initializing the ORB
Fri, 21 Feb 2014 11:00:00.0000000 [HOSTNAME:12856] (IT_ATLI2_IP:203) I - Listener on 0.0.0.0.5000 created


If we start a second server with the same values then port 5001 will be used:
C:\\apps\\orbix6.3.6x32\\asp\\6.3\\demos\\corba\\orb\\simple_fixed_port\\cxx_server>server -ORBevent_log:filters IT_ATLI2_IP=* -ORBpolicies:iiop:server_address_mode_policy:port_range 5000:5001 -ORBplugins:iiop:ip:reuse_addr false


Initializing the ORB
Fri, 21 Feb 2014 11:00:00.0000000 [HOSTNAME:12856] (IT_ATLI2_IP:203) I - Listener on 0.0.0.0.5001 created

Note that reuse_addr is set to false, otherwise this server would also listen on port 5000.

However, if we restrict the setting to 5000:5000 then the server will always listen on port 5000:

C:\\apps\\orbix6.3.6x32\\asp\\6.3\\demos\\corba\\orb\\simple_fixed_port\\cxx_server>server -ORBevent_log:filters IT_ATLI2_IP=* -ORBpolicies:iiop:server_address_mode_policy:port_range 5000:5000 -ORBplugins:iiop:ip:reuse_addr false


Initializing the ORB
Fri, 21 Feb 2014 11:00:00.0000000 [HOSTNAME:12856] (IT_ATLI2_IP:203) I - Listener on 0.0.0.0.5000 created


This is the behaviour of a C server when using this approach. Java servers read the port range differently. C servers include the From_Port and To_Port in its range, Java servers only include from the From_Port and up to and not including the To_Port in the range. If a Java server is started with the same From_Port and To_Port as in the C example above then it will listen on a random port, for example this server listens on 53751 and not 5000:
C:\\apps\\orbix6.3.6x32\\asp\\6.3\\demos\\corba\\orb\\simple_fixed_port\\java>java -cp classes;%CLASSPATH% simple.Server -ORBevent_log:filters IT_ATLI2_IP=* -ORBpolicies:iiop:server_address_mode_policy:port_range 5000:5000


Initializing ORB 11:13:45 2/21/2014 [_it_orb_id_1@HOSTNAME/192.168.100.123] (IT_ATLI2_IP:203) I - listener created, local address: IPAddressImplBase[inet_address=/0.0.0.0,port=53751,protocol=TCP]


If the range is set from 5000 to 5001 then the server will listen on 5000:
C:\\apps\\orbix6.3.6x32\\asp\\6.3\\demos\\corba\\orb\\simple_fixed_port\\java>java -cp classes;%CLASSPATH% simple.Server -ORBevent_log:filters IT_ATLI2_IP=* -ORBpolicies:iiop:server_address_mode_policy:port_range 5000:5001


Initializing ORB 11:14:02 2/21/2014 [_it_orb_id_1@HOSTNAME/192.168.100.123] (IT_ATLI2_IP:203) I - listener created, local address: IPAddressImplBase[inet_address=/0.0.0.0,port=5000,protocol=TCP]


If there is already a server running on port 5000 and another server starts with these same values then it will not be able to run as it will only try to listen on port 5000:
C:\\apps\\orbix6.3.6x32\\asp\\6.3\\demos\\corba\\orb\\simple_fixed_port\\java>java -cp classes;%CLASSPATH% simple.Server -ORBevent_log:filters IT_ATLI2_IP=* -ORBpolicies:iiop:server_address_mode_policy:port_range 5000:5001 -ORBplugins:iiop:ip:reuse_addr false


Initializing ORB 11:28:40 2/21/2014 [_it_orb_id_1@HOSTNAME192.168.100.123] (IT_IIOP:15) E - failed to create listener on IPAddressImplBase[inet_address=/0.0.0.0,port=5000,protocol=TCP] - exception: listener creation failure: java.lang.reflect.InvocationTargetException
Exception in thread "main" org.omg.CORBA.TRANSIENT: vmcid: 0x49540000 minor code: 962 completed: No
at com.iona.corba.atli_protocol.ip.ServiceEndpointManager.create_listener(Unknown Source)
at com.iona.corba.atli_protocol.ip.ServiceEndpointManager.listen_to(Unknown Source)
at com.iona.corba.iiop.IIOPServiceEndpointManagerImpl.add_profile_endpoints(Unknown Source)
at com.iona.corba.art.ior.EndpointImpl.<init>(Unknown Source)
at com.iona.corba.art.ior.EndpointManagerImpl.create_endpoint(Unknown Source)
at com.iona.corba.poa.POAImpl.create_endpoint(Unknown Source)
at com.iona.corba.poa.POAImpl.setup(Unknown Source)
at com.iona.corba.poa.POAPerORBState.<init>(Unknown Source)
at com.iona.corba.poa.POAPlugIn.ORB_init(Unknown Source)
at com.iona.corba.art.artimpl.ORBDelegate.init_plugin(Unknown Source)
at com.iona.corba.art.artimpl.ORBDelegate.resolve_initial_references(Unknown Source)
at com.iona.corba.art.artimpl.ORBImpl.resolve_initial_references(Unknown Source)
at simple.Server.main(Unknown Source)



Notes
See Related Article(s):
http://community.microfocus.com/microfocus/corba/orbix/w/knowledge_base/22702.how-to-set-the-ports-available-to-an-orbix-application.aspx


#orbix6portport.range
#Orbix
#KnowledgeDocs