我正在尝试使用带有 tyrus 1.8.2 的编程端点创建一个 websocket 服务器。我发现构造函数:
public Server(String hostName,
int port,
String contextPath,
Map<String,Object> properties,
Class<?>... configuration)
不接受实现 ServerEndpointConfig 的类。当我尝试它抛出一个 DeploymentException “类 XXX 不是 ServerApplicationConfig 后代,也没有 @ServerEndpoint 注释。”
由于我使用的是编程端点(未注释),这似乎意味着我必须实现 ServerApplicationConfig。这与 websocket API 文档相反。
因此,当我实现 ServerApplicationConfig 时,我不再遇到此异常,并且服务器似乎启动没有问题,但它返回 404 我认为是有效的连接尝试(正确的主机、端口和上下文路径。)
我错过了什么?
附加信息:我扩展了 TyrusServerEndpointConfigurator 并为 modifyHandshake() 方法提供了覆盖。服务器在没有调用此方法的情况下返回 404。