• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

listen on multiple ports

 
Paul Erion
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible for a single instance of Tomcat to listen on multiple ports?

Thanks,

aul
 
Carl Sampson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yes and no. It can be listening on one port for HTTP and another for HTTPS, for example. But I don't think it can listen using the HTTP transport on multiple protocols, for example.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sampson is right... We can specify multiple ports for different protocols...

Paul Erion, if you are trying to assign multiple port for a single protocol, how can Tomcat know which protocol to use, when it get a certain request with different port numbers.... Tomcat will use to a suitable protocol, according to the port number it gets...

Hope it helps..
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Erion:
Is it possible for a single instance of Tomcat to listen on multiple ports?

Thanks,

aul


Sure, you can do it.

Tomcat is support several protocol such as HTTP(80/8080) default, HTTPS.

How to HTTPS on Tomcat ::

http://jakarta.apache.org/tomcat/tomcat-4.1-doc/ssl-howto.html

http://java.sun.com/webservices/docs/1.0/tutorial/doc/WebAppSecurity6.html
 
Budi Kurniawan
author
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Erion:
Is it possible for a single instance of Tomcat to listen on multiple ports?

Thanks,

aul


I think what Paul wanted to know was whether a protocol (HTTP or HTTPS) can listen on multiple ports. The answer is yes. In the server.xml file, find the following (in Tomcat 5):

<Connector port="8080"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />

As you can see, by default Tomcat listens on port 8080. If, for example, you want Tomcat to listen on another port, say 8081, just add this below the previous Connector element:

<Connector port="8081"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" />


The reason for this is this.
The Connector element represents a connector. Upon startup, Tomcat will parse the server.xml file and create objects based on the content of the file. A Connector element will cause Tomcat to create a Connector object. Another Connector element will give you another instance of Connector. With the above configuration, you have 2 connectors listening on port 8080 and 8081 respectively. You only have one container though. The connectors create a request and response object for each incoming HTTP request and pass it to the container.

You can read Chapter 3 of our How Tomcat Works book that discusses connector. This chapter is freely available from www.brainysoftware.com
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the great explanation, Budi... I got them clearly now also...

Even though we can have two connectors listening to different ports, there is only one container which handle the requests from them...
 
Carl Sampson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the advantage to having more than one connector if they both process connections for the same container?
 
Paul Erion
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Budi Kurniawan:


I think what Paul wanted to know was whether a protocol (HTTP or HTTPS) can listen on multiple ports. The answer is yes.
Thanks for the response! And in figuring out what I trying to ask -- I didn't mean to be difficult ... it just always seems to work out that way.

Paul

p.s., I apologize for my signature ... I typically precede my first name with a colon (it's a Lisp thing) and didn't realize it would end up being interpreted as a emoticon.
[ September 16, 2004: Message edited by: Paul Erion ]
 
Simão Fontes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a tomcat 5.5.25 configured with 4 connectors and when it was only one the response time was about 1.30 sec, now it responds in 16 sec.
Does any one know why this migth be?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat is actually a set of components wired together. While mostly it's employed in the out-of-the-box wiring configuration, you can add elements to server.xml to provide multiple Host, Engine, Connector and other such items in a custom architecture.
 
Simão Fontes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is the performance lost.

My server.xml is configured like this:

I had to do this because the applications communicate with them selfs.
For example:
app1 --> app2 --> app3
app2 --> app1 --> app3

When I use all threads for one of the applications, they enter in deadlock (they always need to wait for another application to end).
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need a separate set of ports for each webapp just because they're talking to each other. One port is sufficient. Tomcat will route the requests based on their URL context.

You can get race conditions, "deadly embrace" and resource contention issues without any web architecture at all, however, so I recommend drawing a detailed map of what calls what when, how the components interact, and maybe slap some performance-monitoring on the server in case both apps are trying to make large database operations at the same time.
 
Simão Fontes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answer Tim.

I have 2 applications, wayback and nutchwax, they belong to a search server.

*Nutchwax -> Index -> User
*Wayback -> *Nutchwax -> Index -> User
*Wayback -> *Nutchwax -> Index -> *ArcProxy -> *Browser -> User
* means that this is a application of tomcat

The fact is when I configure Tomcat to have 100 MaxThreads and then I make 100 simultaneous requests to Wayback the threads stop responding, keeps waiting for the arcproxy application, this application doesn't have any free thread to use.

Thanks in advance for the help.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic