小编naf*_*naf的帖子

使用 Jetty 11 设置 websocket

我正在尝试从 Jetty 9.4 迁移到 Jetty 11(可能太早了?),但未能调整用于设置 websockets 的代码。我在 9.4 中实现这一点的方法如下:

Server server = new Server();
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion(false);
HttpConnectionFactory httpFactory = new HttpConnectionFactory(httpConfig);
ServerConnector httpConnector = new ServerConnector(server, httpFactory);
httpConnector.setPort(port);
server.setConnectors(new Connector[] { httpConnector });

// Setup the basic application "context" for this application at "/"
// This is also known as the handler tree (in jetty speak)
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");

// Add a websocket to a specific path spec
ServletHolder holderEvents2 = new …
Run Code Online (Sandbox Code Playgroud)

java jetty websocket

7
推荐指数
1
解决办法
7177
查看次数

标签 统计

java ×1

jetty ×1

websocket ×1