Just connecting from a browser?

136 views
Skip to first unread message

David Aronchick

unread,
Jun 1, 2020, 4:44:28 PM6/1/20
to Gremlin-users
I apologies for such a basic question, but I can't seem to figure out how to do this and the docs are all very specific.

I'm just trying to connect to a standard Gremlin DB (Cosmos) using gremlin. It works great from the server, but when I connect from the browser, I get this error:

Error: ws does not work in the browser. Browser clients must use the native WebSocket object

Here is the code:


Nothing terribly complicated, and the error seems to be pretty clear.

    
constructor() {
        var authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`/dbs/${config.database}/colls/${config.collection}`config.primaryKey);
        this.gremlin_config_options = {
            authenticator,
            traversalsource"g",
            rejectUnauthorizedtrue,
            mimeType"application/vnd.gremlin-v2.0+json"
        }

       var DriverRemoteConnection = Gremlin.driver.DriverRemoteConnection;
        this.Graph = Gremlin.structure.Graph;
        
        var dc = new DriverRemoteConnection(this.gremlin_websocket,this.gremlin_config_options);

        this.graph = new this.Graph();
        this.g = this.graph.traversal().withRemote(this.gremlin_websocket);
      };


When I do the following code, it completes without the Javascript error.


    constructor() {
        var authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`/dbs/${config.database}/colls/${config.collection}`config.primaryKey);
        this.gremlin_config_options = {
            authenticator,
            traversalsource"g",
            rejectUnauthorizedtrue,
            mimeType"application/vnd.gremlin-v2.0+json"
        }

        this.Graph = Gremlin.structure.Graph;
        
        this.gremlin_websocket = new WebSocket('ws://test_db.gremlin.cosmos.azure.com:8182/')

        var dc = new DriverRemoteConnection(this.gremlin_websocket,this.gremlin_config_options);

        this.graph = new this.Graph();
        this.g = this.graph.traversal().withRemote(this.gremlin_websocket);
      };



However, I need to pass along authentication and collection information (currently in the authenticator object). But WebSocket doesn't seem to support it, and Driver Remote Connection doesn't seem to natively take the websocket. What should I do?

Stephen Mallette

unread,
Jun 2, 2020, 7:30:41 AM6/2/20
to gremli...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0eaacb2e-326f-4811-bcdb-d7753579252f%40googlegroups.com.

David Aronchick

unread,
Jun 2, 2020, 8:29:13 AM6/2/20
to gremli...@googlegroups.com
Oh that is a bummer! What's the preferred alternative?

Stephen Mallette

unread,
Jun 2, 2020, 8:47:32 AM6/2/20
to gremli...@googlegroups.com
I don't know that there is one. Judging from the comments on the original PR it seemed like that branch worked for people somehow. The reason for not merging was more with getting what I think were environmental issues with our test cases, not functionality. Perhaps you can try out the branch and see how it works for you.

David Aronchick

unread,
Jun 2, 2020, 10:32:40 AM6/2/20
to Gremlin-users
I'll try that - this is an extremely low volume app, is there an alternative Gremlin solution here? I'm just looking to read-only download data :(

Do people just not use graph db backed websites?
To unsubscribe from this group and stop receiving emails from it, send an email to gremli...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremli...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremli...@googlegroups.com.

Stephen Mallette

unread,
Jun 2, 2020, 10:36:37 AM6/2/20
to gremli...@googlegroups.com
maybe someone will correct me, but i don't think there was any particular reason to not support browsers. it was just an initial design choice.

To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/c0918667-77bb-40ab-94e0-a19884276f7d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages