sockjs-netty icon indicating copy to clipboard operation
sockjs-netty copied to clipboard

Problem with using external sockJS server

Open matyas-igor opened this issue 10 years ago • 0 comments

Hi, Carl! Your implementation of sockJS client is really awesome, but I can't use it because I can't send subscribe message. I'm using external implementation of sockJS server (on PHP).

In javascript client code was like:

        sockjs = new SockJS('/echo');
        sockjs.onopen = function() {
            sockjs.send(JSON.stringify({subscribe: ['orders', 'deals']}));
            $('div').append('open '+ sockjs.protocol+'<br />');
        };

But I can't send it same message in java using your library.

I've tried to use something like:

            ClientBootstrap clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
            SessionClient sessionClient = new SessionClient("http://localhost:8080/echo");

            WebSocketClient webSocketClient = new WebSocketClient(clientBootstrap, new URI("http://localhost:8080/echo"), sessionClient);
            ChannelFuture channelFuture = webSocketClient.connect();

            Channel channel = channelFuture.getChannel();
            webSocketClient.setChannel(channel);

            webSocketClient.send("{\"subscribe\":[\"orders\",\"deals\"]}");

But in this case I got message:

WARNING: The pipeline contains no upstream handlers; discarding: [id: 0x68cc8000, /192.168.1.107:49412 => n1.bbroyal.net/178.62.180.105:8080] EXCEPTION: java.lang.IllegalArgumentException: unsupported message type: class org.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame

matyas-igor avatar Oct 13 '14 09:10 matyas-igor