Closed 37 closed 8 years ago
Hey @LovelyHorse . This is probably better suited on the Apache TinkerPop dev mailing list, or on the gremlin-users mailing list.
For reference the documentation on writing drivers is located here and should be up to date. The part that you will be interested in is :
[...] The above JSON represents the "body" of the request to send to Gremlin Server. When sending this "body" over websockets Gremlin Server can accept a packet frame using a "text" (1) or a "binary" (2) opcode. Using "text" is a bit more limited in that Gremlin Server will always process the body of that request as JSON. Generally speaking "text" is just for testing purposes.
The preferred method for sending requests to Gremlin Server is to use the "binary" opcode. In this case, a "header" will need be sent in addition to to the "body". The "header" basically consists of a "mime type" so that Gremlin Server knows how to deserialize the RequestMessage.
The first byte represents the length of the "mime type" string value that follows. Given the default configuration of Gremlin Server, this value should be set to application/json. The "payload" represents the JSON message above encoded as bytes. Note : Gremlin Server will only accept masked packets as it pertains to websocket packet header construction.
So there are a few points you will need to look at in your code:
ws
client set to send packets as masked
(1
)ws
client set to set the packet frame with a binary
(2
) opcodestring msg = mimeLength + mime + payload (json)
Also you should have :
op
: "eval"
processor
: ""
or "session"
Feel free to link to a thread or something on the lists. I can definitely help you out if need be.
Hey @PommeVerte, thanks for taking the time to post such a detailed answer. Greatly appreciated :).
@LovelyHorse Did you have some luck by looking at the relevant part of the code here? I also suggest posting to the Apache TinkerPop dev mailing list. Closing this but please feel free to post your progress here.
@PommeVerte thank you for the help!
@jbmusso Taking everything mentioned above into consideration I found that I had to change my bindings and rebindings entries from \" \" to {} and it worked perfectly. It was quite confusing that an improperly formatted bindings entry threw the error 'invalid opProcessor' though that's a bug I'll add to the TP3 Jira!
Side note for anyone who finds this with similar issues: The mimecode was unnecessary in my case. Simply beginning the request body with curly brackets did the job. Thanks again.
Side note for anyone who finds this with similar issues: The mimecode was unnecessary in my case. Simply beginning the request body with curly brackets did the job. Thanks again.
FYI this refers to the following part of the TP3 documentation :
Gremlin Server can accept a packet frame using a "text" (1) or a "binary" (2) opcode. Using "text" is a bit more limited in that Gremlin Server will always process the body of that request as JSON. Generally speaking "text" is just for testing purposes.
Using "text" implies an application/json
mimeType so you indeed do not need to add it and can just send the JSON. But it comes with some production level caveats. Like not being able to use the current typed JSON format, nor the new upcoming JSON format and Gremlin Language Variants (GLVs) features (like ByteCode queries). So in general it's best to move away from it for better coverage of TP3 features.
For anyone landing on this issue because of Invalid OpProcessor requested [null]
(sorry for piggybacking your issue :pray: ).
In my case I was trying to use TextP.regex
but the server was not recent enough to use it, resulting in this error message. Server logs:
org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: Could not deserialize the JSON value as r
equired. Nested exception: org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: Could not deserialize the JSON value as required. N
ested exception: java.lang.IllegalStateException: org.apache.tinkerpop.gremlin.process.traversal.TextP.regex(java.lang.String)
Changing from TextP.regex
to TextP.contains
fixed it, possibly because I was not using the right version for the server.
This is probably not the most relevant issue (i'm not using this library) but I can't find anything relevant on the Tinkerpop3 JIRA or Titan 1.x docs or github generally.. So you'll have to forgive me if this is out of place.
I'm having an immense amount of trouble communicating with my gremlin / titan server via websockets using C++. Logically this shouldn't be too hard, though I think the API is changing so drastically that none of the documentation I find has an accurate explanation of the message structure / format.
I'm using the easywsclient library, and an example of my code (and format) is as follows:
std::unique_ptr ws(WebSocket::from_url("ws://SERVER:8182/"));
To which my erroneous response is:
{"requestId":null,"status":{"message":"","code":499,"attributes":{}},"result":{"data":"Invalid OpProcessor requested [null]","meta":{}}}
I cannot seem to find any variation of op or processor (I have tried blank) that returns anything but the above.
Any help or tips would be greatly appreciated!