[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] websocket-jetty-server not able to upgrade request to websocket
|
- From: Yash Sharma <ysharma@xxxxxxxxx>
- Date: Fri, 8 Mar 2024 06:14:18 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=egain.com; dmarc=pass action=none header.from=egain.com; dkim=pass header.d=egain.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n39QFdSxnBVVYvRoVwk4+kvapWiQv9b9tY1hQnOgtqw=; b=ZW3iWpDJgyhoqCnlr0LlaIltIJ81H+bf5jOhMZ6noBY/X0+lEGJ/XcDx0LsFOhDNMWT9wWNfd3exyF5Pu19y7lCo20HCdJiBn340fCH5E8t3nEhDj0mwZgV9S7IpEHusBWq8eyV/P2h0fpb/hcfBQNMk4ZbYso+o42UnUQ2nqU74hg2uazhad1szJc5FwcF8D5QcZjq9RreY411ERnS5SqDn+cRtSSgeRtpZU0TZCVSV2ozwwdsimiXFL8oKdy1sRVKMK65OTJ/FglK2sM84bouRb14YpkLCxbdja2AQgsGHJ+rT7KExyb1l3UqhImZzjcn91J51oiqNyB9qZDJJIQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CchEGsGDb5fpTtLMM+w1zQEl/xoFFZ5Y9hLEQ9iy18kyIFvRnnEkc/fg7nl4LBuvzUoSmAAPm+Phzrx7teCmx82dR2qXoMY5g2cgOvY2/ZAayBqHsVjR1Ly5meNV14CWkYwLa6F5DMcRjyduhoqXKybzN/+4JgmoI2YCyd8kIjt9Me/YCXY5t3VYlpFLCL0OgkacWgtHpYIEejQXZl27jcqfzuzDYveKxVRV5JMSZQn9C8ixQUvuESJpTceY5kBzLVv/JqmxItR94mzOL2vYQOUlWr6q9RPk1lAQJZJFr1PMB7rTTWA0053+vN8mX0eKYZmQuJOn1Xze0NTOLonz0A==
- Delivered-to: jetty-users@xxxxxxxxxxx
- List-archive: <https://www.eclipse.org/mailman/private/jetty-users/>
- List-help: <mailto:jetty-users-request@eclipse.org?subject=help>
- List-subscribe: <https://www.eclipse.org/mailman/listinfo/jetty-users>, <mailto:jetty-users-request@eclipse.org?subject=subscribe>
- List-unsubscribe: <https://www.eclipse.org/mailman/options/jetty-users>, <mailto:jetty-users-request@eclipse.org?subject=unsubscribe>
- Thread-index: AdpxH1YdVbjW31dLS02NwRmH2nYwNw==
- Thread-topic: websocket-jetty-server not able to upgrade request to websocket
Hi All,
I am trying to make websocket connection using html and _javascript_.
My client is as follows:
const socketUrl = "ws://host:port/example";
const socket = new WebSocket(socketUrl);[
And I have Servlet as follows
@WebServlet(name = "WebSocket Servlet", urlPatterns = { "/example" })
public class MyWSServlet extends JettyWebSocketServlet
{
@Override
public void configure(JettyWebSocketServletFactory factory) {
factory.setIdleTimeout(Duration.ofSeconds(1000));
factory.register(MySocket.class);
factory.addMapping("/", (req,res)->new MySocket());
}
}
@WebSocket
public class MySocket{
@OnWebSocketConnect
public void onConnect(Session session) {
System.out.println("Connect: " + session.getRemoteAddress());
}
}
I am using websocket-jetty-server dependency in pom.xml
When I try to hit the ws api, at server side I see that in upgradeRequest() validateNegotiation returns false and hence request is not upgraded to websocket.
As per chat gpt negotiateHeaders() is responsible to add Upgrade:websocket in request headers. But I do not see that happening in jetty.
I have attached stack trace for reference. Can someone please help me with this problem to establish a websocket connection using jetty?
The message that I see in browser console is “connection to 'ws://host:port/example' failed:”
Thanks,
Yash Sharma
|
Attachment:
StackTraceAtServer.JPG
Description: StackTraceAtServer.JPG