2
votes

I am trying to create a websocket server using programmatic endpoints with tyrus 1.8.2. I have found that the constructor:

public Server(String hostName,
  int port,
  String contextPath,
  Map<String,Object> properties,
  Class<?>... configuration)

does not accept a class implementing ServerEndpointConfig. When I try that it throws a DeploymentException "Class XXX is not ServerApplicationConfig descendant nor has @ServerEndpoint annotation."

Since I am using programmatic endpoints (not annotated), this would seem to imply that I must implement ServerApplicationConfig. That is contrary to the websocket API documentation.

So when I implement ServerApplicationConfig, I no longer get this exception, and the server appears to start without problems, but it returns 404 to what I believe are valid connection attempts (correct host, port, and context path.)

What am I missing?

Additional information: I extended TyrusServerEndpointConfigurator and provided an override for the modifyHandshake() method. The server is returning 404's without ever calling this method.

1
I see that you already answered your own question, but you are incorrect that Tyrus violates the specification. ServerApplicationConfig MUST be implemented when you are deploying programmatic endpoint. Annotated endpoints are fine without it. (and to be absolutely correct spec-wise: standalone server is not part of the specification, so Tyrus can do whatever it wants in this case). - Pavel Bucek
The documentation that I am referring to is the Tyrus 1.8.2 Server constructor documentation: - Charlie Davis

1 Answers

0
votes

The problem turned out to be confusion about the way Tyrus constructs the context path. There is a path passed to the Server constructor, and a path returned by the ServerEndpointConfig getPath() method. These are concatenated to form the full context path.

So if you specify "/server" in the Server constructor and "/endpoint" in ServerEndpointConfig.getPath(), the server will accept connection requests on "/server/endpoint".