You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Palmer Cox <pa...@gmail.com> on 2015/03/25 19:08:40 UTC
Fwd: Can't connect to echo.websocket.org using WebSocket client
Hi,
No matter what I've tried, I'm unable to get the Tomcat WebSocket
client to connect to ws://echo.websocket.org. I get the (slightly
edited) Exception:
javax.websocket.DeploymentException: The HTTP request to initiate the
WebSocket connection failed
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:357)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:164)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:181)
at com.myApp.MyClass.test(MyClass.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
... 41 more
Caused by: java.io.EOFException
at org.apache.tomcat.websocket.WsWebSocketContainer.processResponse(WsWebSocketContainer.java:606)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:309)
If I try to connect to ws://echo.websocket.org, I instead get:
javax.websocket.DeploymentException: The HTTP request to initiate the
WebSocket connection failed
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:357)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:164)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:181)
at com.myApp.MyClass.test(MyClass.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
... 41 more
Caused by: java.util.concurrent.ExecutionException:
java.lang.IllegalStateException: Unexpected Status of SSLEngineResult
after an unwrap() operation
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$WrapperFuture.get(AsyncChannelWrapperSecure.java:508)
at org.apache.tomcat.websocket.WsWebSocketContainer.processResponse(WsWebSocketContainer.java:604)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:309)
... 51 more
Caused by: java.lang.IllegalStateException: Unexpected Status of
SSLEngineResult after an unwrap() operation
at org.apache.tomcat.websocket.AsyncChannelWrapperSecure$ReadTask.run(AsyncChannelWrapperSecure.java:313)
I've tried with Tomcat 8.0.20 and Trunk as of today.
Thanks,
-Palmer Cox
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Fwd: Can't connect to echo.websocket.org using WebSocket client
Posted by Mark Thomas <ma...@apache.org>.
On 25/03/2015 19:05, Palmer Cox wrote:
> On Wed, Mar 25, 2015 at 2:37 PM, Mark Thomas <ma...@apache.org> wrote:
>> On 25/03/2015 18:08, Palmer Cox wrote:
>>> Hi,
>>>
>>> No matter what I've tried,
>>
>> And the list members have no idea what you have tried since you haven't
>> told us.
>>
>> Take a look at Tomcat's unit tests for WebSocket. There are a number of
>> working examples you can use as a basis for you code.
>
> Maybe I phrased my last email badly.
No, you simply left out any useful information. All you said was "It
doesn't work and here is the error message I got" which is about as much
use as a chocolate teapot for the rest of us since we have no idea what
it was that didn't work.
> Anyway, I have the following program:
Much better. Thanks.
> public class App2 {
> @ClientEndpoint
> public static class Client {
> @OnOpen
> public void onOpen(Session s) throws Exception {
> System.out.println("Sending PING");
> s.getBasicRemote().sendText("PING");
> }
>
> @OnMessage
> public void onMessage(Session s, String msg) throws Exception {
> System.out.println("GOT: " + msg);
> Thread.sleep(1000);
> s.getBasicRemote().sendText("PING");
> System.out.println("Sending PING");
> }
> }
>
> public static void main(final String[] args) throws Exception {
> ContainerProvider.getWebSocketContainer().connectToServer(
> Client.class,
> URI.create("ws://echo.websocket.org"));
> Thread.sleep(Long.MAX_VALUE);
> }
> }
>
> This works fine with Tyrus 1.10. However, when I run it with the
> websocket libraries from Tomcat 8.0.20, I get:
>
> Exception in thread "main" javax.websocket.DeploymentException: The
> HTTP request to initiate the WebSocket connection failed
> at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:357)
> at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:164)
> at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:181)
> at io.davinci.test_sync_gateway_websocket.App2.main(App2.java:31)
> Caused by: java.io.EOFException
> at org.apache.tomcat.websocket.WsWebSocketContainer.processResponse(WsWebSocketContainer.java:606)
> at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:309)
> ... 3 more
>
>
> I believe this is a bug in the tomcat websocket client libraries, right?
You need to add a trailing / to the URI then it will work.
Yes, I'd agree that that is a bug in the Tomcat WebSocket client
libraries. Please open a Bugzilla issue.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Fwd: Can't connect to echo.websocket.org using WebSocket client
Posted by Palmer Cox <pa...@gmail.com>.
On Wed, Mar 25, 2015 at 2:37 PM, Mark Thomas <ma...@apache.org> wrote:
> On 25/03/2015 18:08, Palmer Cox wrote:
>> Hi,
>>
>> No matter what I've tried,
>
> And the list members have no idea what you have tried since you haven't
> told us.
>
> Take a look at Tomcat's unit tests for WebSocket. There are a number of
> working examples you can use as a basis for you code.
Maybe I phrased my last email badly. Anyway, I have the following program:
public class App2 {
@ClientEndpoint
public static class Client {
@OnOpen
public void onOpen(Session s) throws Exception {
System.out.println("Sending PING");
s.getBasicRemote().sendText("PING");
}
@OnMessage
public void onMessage(Session s, String msg) throws Exception {
System.out.println("GOT: " + msg);
Thread.sleep(1000);
s.getBasicRemote().sendText("PING");
System.out.println("Sending PING");
}
}
public static void main(final String[] args) throws Exception {
ContainerProvider.getWebSocketContainer().connectToServer(
Client.class,
URI.create("ws://echo.websocket.org"));
Thread.sleep(Long.MAX_VALUE);
}
}
This works fine with Tyrus 1.10. However, when I run it with the
websocket libraries from Tomcat 8.0.20, I get:
Exception in thread "main" javax.websocket.DeploymentException: The
HTTP request to initiate the WebSocket connection failed
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:357)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:164)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:181)
at io.davinci.test_sync_gateway_websocket.App2.main(App2.java:31)
Caused by: java.io.EOFException
at org.apache.tomcat.websocket.WsWebSocketContainer.processResponse(WsWebSocketContainer.java:606)
at org.apache.tomcat.websocket.WsWebSocketContainer.connectToServer(WsWebSocketContainer.java:309)
... 3 more
I believe this is a bug in the tomcat websocket client libraries, right?
-Palmer Cox
> <snip/>
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Fwd: Can't connect to echo.websocket.org using WebSocket client
Posted by Mark Thomas <ma...@apache.org>.
On 25/03/2015 18:08, Palmer Cox wrote:
> Hi,
>
> No matter what I've tried,
And the list members have no idea what you have tried since you haven't
told us.
Take a look at Tomcat's unit tests for WebSocket. There are a number of
working examples you can use as a basis for you code.
<snip/>
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org