jbmusso / gremlin-javascript

JavaScript tools for graph processing in Node.js and the browser inspired by the Apache TinkerPop API
MIT License
214 stars 63 forks source link

Confirming this library runs in the browser ? #103

Open ordinaryorange opened 6 years ago

ordinaryorange commented 6 years ago

I've tried to run the client in chrome to connect to Azure cosmos without luck. Upon inspection via fiddler, the connection does not seem to be promoting to a websocket. I see all tests are node and all examples I can find online are node based.

Is browser possible as per the opening remarks of readme ?

philosaur commented 6 years ago

I am very curious about this as well.

dbugsy commented 6 years ago

Having a similar problem - had a look at the requests and got the following:

GET /gremlin HTTP/1.1
Host: localhost:8182
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Origin: http://localhost:8080
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36
Accept: */*
Referer: http://localhost:8080/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9

This led to a response of 'not a WebSocket handshake request: missing upgrade'.

I tested another websocket connection, which made a successful connection to the same gremlin server, and the request looked like this:

GET /gremlin HTTP/1.1
Host: localhost:8182
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: file://
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Sec-WebSocket-Key: lEslnVBk32uXrH45/G8rSA==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

It looks like this is the same problem - I have been unable to get this library to send a ws connection over the browser.

jbmusso commented 6 years ago

It used to work in the browser in earlier version, about 3 years ago, but I couldn't confirm today (the README is misleading, I confess). I think it shouldn't be too hard to tweak the code to make it work in browsers. The size of the bundle could be an issue though since I never really tried to do optimization there. Any of you willing to have a look?