Hi Chris.

You are right. After opening a dedicated port for my Tomcat instance all is working fine. My servlet code (Jersey resources and ServerEndpoints) does not reference any port. Client code uses window.location.host and picks up any port from the URL. Only drawback is that the URL users enter in the browser contains the port. Apparently, the hosting provider does not want to enable websocket traffic through the front end redirectors and web servers, which I think are Apache web servers. The dedicated port does the trick and enables WS only for my Tomcat instance.

Cheers,
Luigi





-----Original Message----- From: Christopher Schultz
Sent: Thursday, March 24, 2016 1:33 PM
To: Tomcat Users List
Subject: Re: Tomcat 7.0.68 - using websocket @ServerEndpoint to listen on alternate port

Luigi,

On 3/23/16 12:26 PM, Luigi Suardi wrote:
I have a working websocket based application based on Tomcat 7.0.68
examples in my local environment. There are issues (i.e.
java.lang.UnsupportedOperationException: HTTP upgrade is not
supported by the AJP protocol) when running the same in a data
center with an Apache web server front end that acts as a load
balancer.

It's true: the AJP protocol does not support upgrading to other
protocols (e.g. websocket, HTTP/2).

In this scenario, the Java hosting provider is asking me to run
websocket traffic through separate dedicated port XXXX. So I would
have to respond to regular HTTP requests over default 8080 port and
to HTTP websocket requests over port XXXX. Is it possible to still
use the annotated @ServerEndpoint or similar approach and tell it to
listen on the XXXX port? How can I do this under Tomcat?

You shouldn't need to do that: Tomcat will take care of the port
mappings; just write your application as usual without any port numbers.
If you have a client using a ws:// URL, they will connect through port
XXXX and the upgrade should succeed. I'm not exactly sure how the web
server will be configured to handle this, though. Or were you planning
to generate ws:// URLs with embedded port numbers?

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to