JanusGraph / JanusGraph/janusgraph

Version 0.4.0 does not return results with websocket connection

Open
#1,674 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

I have a React app that connects to Janusgraph over a websocket connection. This worked well in version JanusGraph 0.3.1. I installed version 0.4.0 and it works with the gremlin console, but when trying to connect from javascript websocket with the following simplified sample websocket call:

const WebSocketAsPromised = require('websocket-as-promised');

getGraphNames = () => {
let gremlin_query = 'ConfiguredGraphFactory.getGraphNames();';
this.run_websocket_request(gremlin_query)
.then(response => {
if (response) {
console.log('GetGraphIds: ', response);
}
});
}

run_websocket_request(gremlin_query, reqid = null, close = false) {
return new Promise((resolve, reject) => {
var wsstring = 'ws://localhost:8182/gremlin';
const wsp = new WebSocketAsPromised(wsstring, {
packMessage: data => JSON.stringify(data),
unpackMessage: message => JSON.parse(message)
});
wsp.onMessage.addListener(message => {
var response = JSON.parse(message);
//console.log('run_websocket_request: ', response.result.data);
if (!reqid) {
wsp.close();
return resolve(response.result.data);
} else {
if (close) {
wsp.close();
}
return resolve(response.result.data);
}
});

wsp.onClose.addListener(event => console.log('Connections closed: ', event.reason));

wsp.open()
.then(() => wsp.sendPacked(msg))
.catch(err => {
console.log('Error: ', err);
reject(err);
}
);
});
}

I get no response and I get the following error in the server logs:

```
6645484 [gremlin-server-worker-1] WARN io.netty.channel.DefaultChannelPipeline - An
exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means
the last handler in the pipeline did not handle the exception.
io.netty.handler.codec.DecoderException: java.lang.ClassCastException:
org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0 cannot be
cast to org.apache.tinkerpop.gremlin.driver.ser.MessageTextSerializer
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:98)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.handler.codec.http.websocketx.Utf8FrameValidator.channelRead(Utf8FrameValidator.java:77)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:204)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at org.apache.tinkerpop.gremlin.server.handler.WsAndHttpChannelizerHandler.channelRead(WsAndHttpChannelizerHandler.java:76)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:647)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:582)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:499)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:461)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException:
org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0 cannot be
cast to org.apache.tinkerpop.gremlin.driver.ser.MessageTextSerializer
at
org.apache.tinkerpop.gremlin.server.handler.WsGremlinTextRequestDecoder.decode(WsGremlinTextRequestDecoder.java:55)
at
org.apache.tinkerpop.gremlin.server.handler.WsGremlinTextRequestDecoder.decode(WsGremlinTextRequestDecoder.java:41)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
... 40 more
```

I also tried using Graphexp and get the same results.

I don't get any results back from the websocket call in the browser console or the network tab.

Contributor guide

Open the contributing guide

Research direction

Start at org.apache.tinkerpop.gremlin.server.handler.WsGremlinTextRequestDecoder.java:55 and inspect how the websocket request is decoded with GraphSONMessageSerializerGremlinV2d0. Compare the 0.3.1 and 0.4.0 websocket behavior using the simplified JavaScript request and the Graphexp client. Done means a JavaScript websocket connection returns results without the MessageTextSerializer ClassCastException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, javascript
Domain
databases, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.