users@tyrus.java.net

Re: Exception connecting to server

From: Petr Janouch <petr.janouch_at_oracle.com>
Date: Sun, 13 Mar 2016 23:14:47 +0100

Hi,

The message

> org.glassfish.tyrus.core.HandshakeException: Response code was not
> 101: 400.

might not have the most user friendly formatting, but it says that you got 400 from the server.
I have tried the WebSocketServlet echo example shipped with Tomcat 7.0.68 (ws://localhost:8080/examples/websocket/tc7/echoMessage) with Tyrus client and it worked fine.

If I were you, I would just put a breakpoint in the WebSocketServlet to see why it returns the 400 (provided that the 400 does not come from somewhere else). It is quite a simple piece of code.
Btw I have noticed that WebSocketServlet is deprecated event on Tomcat 7 (at least 7.0.68).

Sorry that I cannot be more of help.

Petr



On 11 Mar 2016, at 21:49, scott_at_tnstaafl.net wrote:

> I'm trying to use Tyrus v 1.12 in a Java client. When I attempt to
> connect to the server I get two exceptions
>
> javax.websocket.DeploymentException: Handshake error
>
> followed by
> org.glassfish.tyrus.core.HandshakeException: Response code was not
> 101: 400.
>
> I have a javascript client that connects fine.
>
> The server is on Tomcat 7 with a servlet extending WebSocketServlet. I
> can't move to Tomcat 8.
>
> My connect code is
>
> ClientManager client = ClientManager.createClient();
> client.connectToServer(new Endpoint() ... }, cec, new
> URI("ws://localhost/admin/EditorComm"));
>
> The servlet does call its init() function when first try to connect,
> but it never creates a inbound socket.