users@tyrus.java.net

Re: Using tyrus to run standalone websocket Server : Connectivity issues

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Mon, 24 Jun 2013 19:19:14 +0200

Hello,

you cannot use Server(Class<?>) constructor with programmatic endpoints.

you can rewrite "server/EchoWebSocketEndpoint" to annotated variant
(@ServerEndpoint, etc) or provide ServerApplicationConfig or
ServerEndpointConfig implementation instance, see [1].

Pavel

[1]
https://tyrus.java.net/apidocs/1.0/org/glassfish/tyrus/server/Server.html#Server%28java.lang.Class...%29


On 6/24/13 6:56 PM, singh.kr.vivek_at_gmail.com wrote:
> Hi,
> I am using tyrus in stand-alone mode to create a new websocket server
> instance.
>
> Using programatic way of server creation I believe the end point should
> be ws://localhost:8025/websockets/tests
>
> When trying to connect using ClientManager.connectToClient(...), server
> returns a 404 error.
>
> public class EchoWebSocketEndpoint extends Endpoint {
>
> @Override
> public void onOpen(Session session, EndpointConfig config) {
> final RemoteEndpoint.Basic endPoint =
> session.getBasicRemote();
>
> session.addMessageHandler(new
> MessageHandler.Whole<String>() {
> @Override
> public void onMessage(String message) {
> try {
>
> endPoint.sendText(System.currentTimeMillis() + " " + message);
> } catch (IOException e) {
> e.printStackTrace(); //To
> change body of catch statement use File | Settings | File Templates.
> }
> }
> });
>
>
> }
> }
>
> Server End Point Code is located at
> https://github.com/mail2vks/tyrus-sample/blob/master/src/main/java/org/
> vivek/j2ee/websockets/server/EchoWebSocketEndpoint.java
>
> If this mailing list is not the right place, kindly guide me to
> appropriate list.
>
>