Re: [jetty-users] EXTERNAL- Re: websocket-jetty-server not able to upgrade request to websocket

2024-03-12 Thread Yash Sharma via jetty-users
Hi,

Actually my websocket url is going through AWS API Gateway resource which sends 
request to server as plain http request hence it is failing to upgrade.  By 
bypassing AWS it is working fine. I have to figure out how Integration Request 
configuration can be done for websocket at AWS side so that the wss protocol is 
not lost.

Thanks for the help @Lachlan Roberts<mailto:lach...@webtide.com>.


From: Lachlan Roberts 
Sent: Tuesday, March 12, 2024 3:35 PM
To: Yash Sharma 
Cc: JETTY user mailing list 
Subject: Re: EXTERNAL- Re: [jetty-users] websocket-jetty-server not able to 
upgrade request to websocket

Hi,

Judging by the partial stack trace you provided your configuration is fine as 
it made it to the websocket negotiation.

Are you saying that no HTTP response was received and the connection was 
aborted?
(normally there would be a 101 response for successful upgrade request and some 
other error code if there was a failure during the upgrade).

Can you please provide the debug logs from Jetty?

cheers,
Lachlan

On Tue, Mar 12, 2024 at 5:26 PM Yash Sharma 
mailto:ysha...@egain.com>> wrote:
Thanks for the input Roberts, actually upgrade request fails for an http 
request made. For  ws:// request I am seeing connection failed. Do I need to 
add websocket-jetty related configuration in jetty.xml configuration file?

Can some please share a snippet of the configuration to be added ?

Thanks,
Yash Sharma

From: Lachlan Roberts mailto:lach...@webtide.com>>
Sent: Monday, March 11, 2024 12:52 PM
To: JETTY user mailing list 
mailto:jetty-users@eclipse.org>>
Cc: Yash Sharma mailto:ysha...@egain.com>>
Subject: EXTERNAL- Re: [jetty-users] websocket-jetty-server not able to upgrade 
request to websocket




CAUTION: This email originated from outside eGain. Do not click links or open 
attachments unless you can verify the sender and know the content is safe.



These two lines do exactly the same thing btw, so might want to remove one
factory.register(MySocket.class);
factory.addMapping("/", (req,res)->new MySocket());
Can you look at the HTTP response to the websocket upgrade request.

You also can enable Jetty debug logging for websocket and see exactly what is 
happening.


On Fri, Mar 8, 2024 at 5:14 PM Yash Sharma via jetty-users 
mailto:jetty-users@eclipse.org>> wrote:
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
___
jetty-users mailing list
jetty-users@eclipse.org<mailto:jetty-users@eclipse.org>
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users
___
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users


Re: [jetty-users] EXTERNAL- Re: websocket-jetty-server not able to upgrade request to websocket

2024-03-12 Thread Lachlan Roberts via jetty-users
Hi,

Judging by the partial stack trace you provided your configuration is fine
as it made it to the websocket negotiation.

Are you saying that no HTTP response was received and the connection was
aborted?
(normally there would be a 101 response for successful upgrade request and
some other error code if there was a failure during the upgrade).

Can you please provide the debug logs from Jetty?

cheers,
Lachlan

On Tue, Mar 12, 2024 at 5:26 PM Yash Sharma  wrote:

> Thanks for the input Roberts, actually upgrade request fails for an http
> request made. For  ws:// request I am seeing connection failed. Do I need
> to add websocket-jetty related configuration in jetty.xml configuration
> file?
>
>
>
> Can some please share a snippet of the configuration to be added ?
>
>
>
> Thanks,
>
> Yash Sharma
>
>
>
> *From:* Lachlan Roberts 
> *Sent:* Monday, March 11, 2024 12:52 PM
> *To:* JETTY user mailing list 
> *Cc:* Yash Sharma 
> *Subject:* EXTERNAL- Re: [jetty-users] websocket-jetty-server not able to
> upgrade request to websocket
>
>
>
>
>
> *CAUTION*: This email originated from outside eGain. Do not click links
> or open attachments unless you can verify the sender and know the content
> is safe.
>
>
>
>
> These two lines do exactly the same thing btw, so might want to remove one
> factory.register(MySocket.class);
> factory.addMapping("/", (req,res)->new MySocket());
>
> Can you look at the HTTP response to the websocket upgrade request.
>
>
>
> You also can enable Jetty debug logging for websocket and see exactly what
> is happening.
>
>
>
>
>
> On Fri, Mar 8, 2024 at 5:14 PM Yash Sharma via jetty-users <
> jetty-users@eclipse.org> wrote:
>
> 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
>
> ___
> jetty-users mailing list
> jetty-users@eclipse.org
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users
>
>
___
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users


Re: [jetty-users] EXTERNAL- Re: websocket-jetty-server not able to upgrade request to websocket

2024-03-12 Thread Yash Sharma via jetty-users
Thanks for the input Roberts, actually upgrade request fails for an http 
request made. For  ws:// request I am seeing connection failed. Do I need to 
add websocket-jetty related configuration in jetty.xml configuration file?

Can some please share a snippet of the configuration to be added ?

Thanks,
Yash Sharma

From: Lachlan Roberts 
Sent: Monday, March 11, 2024 12:52 PM
To: JETTY user mailing list 
Cc: Yash Sharma 
Subject: EXTERNAL- Re: [jetty-users] websocket-jetty-server not able to upgrade 
request to websocket




CAUTION: This email originated from outside eGain. Do not click links or open 
attachments unless you can verify the sender and know the content is safe.



These two lines do exactly the same thing btw, so might want to remove one
factory.register(MySocket.class);
factory.addMapping("/", (req,res)->new MySocket());
Can you look at the HTTP response to the websocket upgrade request.

You also can enable Jetty debug logging for websocket and see exactly what is 
happening.


On Fri, Mar 8, 2024 at 5:14 PM Yash Sharma via jetty-users 
mailto:jetty-users@eclipse.org>> wrote:
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
___
jetty-users mailing list
jetty-users@eclipse.org<mailto:jetty-users@eclipse.org>
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users
___
jetty-users mailing list
jetty-users@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users