Git Product home page Git Product logo

gremlin-php's Introduction

This is a Gremlin server client for PHP. It allows you to run gremlin queries against graph databases (including Neo4j, Titan, etc.). You can find a beginner tutorial by reading the Get up and running with Tinkerpop 3 and PHP article.

This driver currently supports TP3+.

For a TP2 compatible php driver please check rexpro-php

Build Status Latest Stable Version Coverage Status Total Downloads License

Join the chat at https://gitter.im/PommeVerte/gremlin-php

Installation

PHP Gremlin-Server Client

Preferred method is through composer.

Either run :

php composer.phar require brightzone/gremlin-php "3.*"

Or add:

"brightzone/gremlin-php": "3.*"

to the require section of your composer.json file

Tinkerpop 3.3.x server Configuration

This driver now supports GraphSON 3.0 with a basic beta serializer. You can use this serializer by doing :

  $db = new Connection();
  $db->message->registerSerializer('\Brightzone\GremlinDriver\Serializers\Gson3', TRUE);

If you wish to continue using the stable GraphSON 1.0 serializer it is necessary to configure the server to use GraphSON 1.0. To do this, make sure to replace the # application/json serializer in your gremlin-server.yaml configuration file with the following:

- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV1d0]  }}        # application/json

Upgrading

BC breaking changes are introduced between major version changes. So if you're upgrading to 2.0.0 from 1.0. Please read the CHANGELOG

Usage

The Connection class exists within the GremlinDriver namespace.

require_once('vendor/autoload.php');
use \Brightzone\GremlinDriver\Connection;

$db = new Connection;

Features

You can find more information by reading the API.

Basic connection

A basic connection can be created by creating a new Connection as follows.

$db = new Connection([
    'host' => 'localhost',
    'graph' => 'graph'
]);
//you can set $db->timeout = 0.5; if you wish
$db->open();

$result = $db->send('g.V(2)');
//do something with result
$db->close();

Note that "graph" is the name of the graph configured in gremlin-server (not the reference to the traversal which is g = graph.traversal())

It is also possible to specify authentication credentials as follows:

$db = new Connection([
    'host' => 'localhost',
    'graph' => 'graph',
    'username' => 'pomme',
    'password' => 'hardToCrack'
]);
//you can set $db->timeout = 0.5; if you wish
$db->open();
$db->send('g.V(2)');
//do something with result
$db->close();

Check the SSL section for an example using the configuration files provided by TP.

You can find all the options available to the Connection class here.

Bindings

Bindings are important for several reasons. They protect from code injections, but they also prevent the server from having to compile scripts on every run.

The following example illustrates both of these points:

$unsafeUserValue = 2; //This could be anything submitted via form.
$db = new Connection([
    'host' => 'localhost',
    'port' => 8182,
    'graph' => 'graph',
]);
$db->open();

$db->message->bindValue('CUSTO_BINDING', $unsafeUserValue); // protects from injections
$result1 = $db->send('g.V(CUSTO_BINDING)'); // The server compiles this script and adds it to cache

$db->message->bindValue('CUSTO_BINDING', 5);
$result2 = $db->send('g.V(CUSTO_BINDING)'); // The server already has this script so gets it from cache without compiling it, but runs it with 5 instead of $unsafeUserValue
$result3 = $db->send('g.V(5)'); // The script is different so the server compiles this script and adds it to cache

//do something with result
$db->close();

As you can see from the example above, not using bindings can be costly as the server needs to compile every new script.

Sessions

Sessions allow you to maintain variables and bindings accross multiple requests.

$db = new Connection([
    'host' => 'localhost',
    'port' => 8182,
]);
$db->open();
$db->send('cal = 5+5', 'session'); // first query sets the `cal` variable
$result = $db->send('cal', 'session'); // result = [10]
//do something with result
$db->close();

Transactions

Transactions will allow you to revert or confirm a set of changes made accross multiple requests.

$db = new Connection([
    'host' => 'localhost',
    'port' => 8182,
    'graph' => 'graphT',
]);
$db->open();

$db->transactionStart();

$db->send('t.addV().property("name","michael")');
$db->send('t.addV().property("name","john")');

$db->transactionStop(FALSE); //rollback changes. Set to TRUE to commit.
$db->close();

Note that "graphT" above refers to a graph that supports transactions. And that transactions start a session automatically. You can check which features are supported by your graph with graph.features().

It is also possible to express transactions with a lambda notation:

$db = new Connection([
    'host' => 'localhost',
    'port' => 8182,
    'graph' => 'graphT',
]);
$db->open();

$db->transaction(function($db){
    $db->send('t.addV().property("name","michael")');
    $db->send('t.addV().property("name","john")');
}, [$db]);

$db->close();

This will commit these changes or return an Exception if an error occured (and automatically rollback changes). The advantage of using this syntax is that it allows you to handle fail-retry scenarios.

It is sometimes important to implement a fail-retry strategy for your transactional queries. One such example is in the event of concurrent writes to the same elements, the databases (such as titan) will throw an error when elements are locked. When this happens you will most likely want the driver to retry the query a few times until the element is unlocked and the write can proceed. For such instances you can do:

$db = new Connection([
    'host' => 'localhost',
    'port' => 8182,
    'graph' => 'graphT',
    'retryAttempts' => 10
]);
$db->open();

$db->transaction(function($db){
    $db->send('t.addV().property("name","michael")');
    $db->send('t.addV().property("name","john")');
}, [$db]);

$db->close();

This will attempt to run the query 10 times before fully failing. It is worth noting that retryAttempts also works with -out of session- queries:

$db->send('gremlin.code.here'); // will retry multiple times if 'retryAttempts' is set

Advanced features

Message objects

Sometimes you may need to have greater control over individual requests. The reasons for this can range from using custom serializers, different query languages (gremlin-python, gremlin-scala, java), to specifying a request timeout limit or a local alias. For these cases you can construct a custom Message object as follows:

$message = new Message;
$message->gremlin = 'custom.V()'; // note that custom refers to the graph traversal set on the server as g (see alias bellow)
$message->op = 'eval'; // operation we want to run
$message->processor = ''; // the opProcessor the server should use
$message->setArguments([
                'language' => 'gremlin-groovy',
                'aliases' => ['custom' => 'g'],
                // ... etc
]);
$message->registerSerializer('\Brightzone\GremlinDriver\Serializers\Json');

$db = new Connection();
$db->open();
$db->send($message);
//do something with result
$db->close();

Of course you can affect the current db message in the same manner through $db->message.

For a full list of arguments and values available please refer to the TinkerPop documentation for drivers.

SSL

When security is important you will want to use the SSL features available. you can do so as follows:

$db = new Connection([
    'host' => 'localhost',
    'graph' => 'graph',
    'ssl' => TRUE
]);
//you can set $db->timeout = 0.5; if you wish
$db->open();
$db->send('g.V(2)');
//do something with result
$db->close();

Note that with php 5.6+ you will need to provide certificate information in the same manner you would to a stream_context_create(). In which case your Connection() call could look something like the following (replace with your own certificates and/or bundles):

$db = new Connection([
    'host' => 'localhost',
    'graph' => 'graph',
    'ssl' => [
        "ssl"=> [
            "cafile" => "/path/to/bundle/ca-bundle.crt",
            "verify_peer"=> true,
            "verify_peer_name"=> true,
        ]
    ]
]);

If you're using the bundled gremlin-server-secure.yaml file, you can use this configuration to connect to it. For dev and testing purposes you can use this configuration

Serializers

Serializers can be changed on the gremlin-server level. This allows users to set their own serializing rules. This library comes by default with a Json serializer. Any other serializer that implements SerializerInterface can be added dynamically with:

$db = new Connection;
$serializer = $db->message->getSerializer() ; // returns an instance of the default JSON serializer
echo $serializer->getName(); // JSON
echo $serializer->getMimeType(); // application/json

$db->message->registerSerializer('namespace\to\my\CustomSerializer', TRUE); // sets this as default
$serializer = $db->message->getSerializer(); // returns an instance of the CustomSerializer serializer (default)
$serializer = $db->message->getSerializer('application/json'); // returns an instance of the JSON serializer

You can add many serializers in this fashion. When gremlin-server responds to your requests, gremlin-php will be capable of using the appropriate one to unserialize the message.

API

You can find the full api here.

Unit testing

Neo4J is required for the full test suit. It is not bundled with gremlin-server by default so you will need to manually install it with:

bin/gremlin-server.sh -i org.apache.tinkerpop neo4j-gremlin 3.2.8

(replace the version number by the one that corresponds to your gremlin-server version)

Copy the following files :

cp <gremlin-php-root-dir>/build/server/gremlin-server-php.yaml <gremlin-server-root-dir>/conf/
cp <gremlin-php-root-dir>/build/server/neo4j-empty.properties <gremlin-server-root-dir>/conf/
cp <gremlin-php-root-dir>/build/server/gremlin-php-script.groovy <gremlin-server-root-dir>/scripts/

You will then need to run gremlin-server in the following manner :

bin/gremlin-server.sh conf/gremlin-server-php.yaml

Then run the unit test via:

# make sure test dependecies are installed 
composer install # PHP >=5.6
composer update # PHP 5.5

# Run the tests
phpunit -c build/phpunit.xml

Browser /tests/webtest.php file

If your gremlin-php folder is on the web path. You can also load tests/webtest.php instead of using the command line to run PHPUNIT tests.

This is useful in some wamp or limited access command line situations.

gremlin-php's People

Contributors

amore012 avatar dmill-bz avatar gitter-badger avatar koga187 avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gremlin-php's Issues

java.util.ArrayList cannot be cast to java.lang.String

I regularly rebuild from JanusGraph master on my development machine. I also recently updated gremlin-php to latest 3.0.2

As of 2 days ago, I've been getting this error when trying to send certain queries.

A general server error occurred that prevented the request from being processed.
 : java.util.ArrayList cannot be cast to java.lang.String

 ===================  SERVER TRACE  =========================
array (
  'stackTrace' => 'java.lang.ClassCastException: java.util.ArrayList cannot be c
ast to java.lang.String
        at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.evalOp
Internal(AbstractEvalOpProcessor.java:236)
        at org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor.eva
lOp(SessionOpProcessor.java:191)
        at org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channel
Read0(OpExecutorHandler.java:68)
        at org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channel
Read0(OpExecutorHandler.java:43)
        at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChanne
lInboundHandler.java:105)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToM
essageDecoder.java:102)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToM
essageDecoder.java:102)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToM
essageDecoder.java:102)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToM
essageDecoder.java:102)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToM
essageDecoder.java:102)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler
$1.channelRead(WebSocketServerProtocolHandler.java:147)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMes
sageDecoder.java:293)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:267)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1069)
        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:902)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageD
ecoder.java:411)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessage
Decoder.java:248)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(Abstra
ctChannelHandlerContext.java:346)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(Defau
ltChannelPipeline.java:1294)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:367)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(Abst
ractChannelHandlerContext.java:353)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChanne
lPipeline.java:911)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(Abstra
ctNioByteChannel.java:131)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.jav
a:652)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEve
ntLoop.java:575)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.ja
va:489)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:451)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThread
EventExecutor.java:140)
        at java.lang.Thread.run(Unknown Source)
',
  'exceptions' =>
  array (
    0 => 'java.lang.ClassCastException',
  ),
)
 ============================================================

The sample query I'm trying to send is

g.addV(label, 'users', 'users_id', 2244994945, 'name', 'TwitterDev', 'screen_name', 'TwitterDev', 'description', 'Developer and Platform Relations @Twitter. We are developer advocates. We can\'t answer all your questions, but we listen to all of them!', 'followers_count', 429831, 'created_at', 1386995755000, 'verified', true, 'lang', 'en')"

Submitting this query directly in gremlin works but via the gremlin-php lib does not. Any ideas why?

Certain commands return nothing

I am running into an issue with

g.V().drop()

which would drop all vertices. None of the drop queries work for some reason... Once you add iterate() this is supposed to work.

g.V().drop().iterate()

These work fine in Gremlin console but not via PHP.

Running JanusGraph 0.2.0 (w/ Cassandra & ElasticSearch) with bundled gremlin server.

From GremlinServer logs:

87565089 [gremlin-server-worker-1] INFO  org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor  - Initialized gremlin-groovy ScriptEngine with scripts/empty-sample.groovy
87565112 [gremlin-server-session-1] WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes
87565146 [gremlin-server-worker-1] INFO  org.apache.tinkerpop.gremlin.server.op.session.Session  - Session 22a0f71e-433f-4441-b804-5392101c7f74 closed

Can't send traversals

I am connecting to an Azure Cosmos DB gremlin endpoint, but it seems like I can't send any queries.

This is my code:

require_once('vendor/autoload.php');
use \Brightzone\GremlinDriver\Connection;

echo "starting\n";
$db = new Connection;
$db = new Connection([
    'host' => '',
    'username' => '',
    'password' => ''
    ,'graph' => ''
    ,'port' => '443'
]);

$db->timeout = 0.5; 

try {
    echo "Attempting to connect\n";
    $db->open();
    echo "Connected, sending query:\n";
    $result = $db->send('g.V(1)');
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

//do something with result
echo "printing result\n";
print_r($result);

$db->close();

This is the result I am getting:

starting
Attempting to connect
PHP Notice:  Undefined offset: 1 in D:\Projects\azure-cosmos-db-php-sample\vendor\brightzone\gremlin-php\src\Connection.php on line 215
Connected, sending query:
PHP Warning:  Parameter 1 to Brightzone\GremlinDriver\Connection::Brightzone\GremlinDriver\{closure}() expected to be a reference, value given in D:\Projects\azure-cosmos-db-php-sample\vendor\brightzone\gremlin-php\src\Workload.php on line 78
PHP Notice:  Undefined offset: 1 in D:\Projects\azure-cosmos-db-php-sample\vendor\brightzone\gremlin-php\src\Connection.php on line 236
  1. What does the Undefined offset: 1 error mean?
  2. Why do these warnings stop the execution of the program? I am not seeing any errors/exceptions being thrown at the try/catch.
  3. I didn't find this in the documentation. Does this driver implement the RemoteServer connection protocol?

Need to automate the Neo4j password change.

In order to drop the need to access the Neo4j web client and change the password, it should be possible to take the /data/dbms/auth file (after changing the password) and add it to the /build/server directory. Before the server is started, copy the auth file over to the Neo4j installation under /data/dbms.

What do you think?

Scott

Cannot use transactions when connecting to Azure CosmosDB

Im connecting to Azure CosmosDB, and everthing works fine but when i add 'graph' key to connection array, i get gremlin query compilation error.

This is the error when i use 'graphT' just like in your examples:

Gremlin Query Compilation Error: Unable to resolve symbol 'graphT' in the current context. @ line 1, column 1.

start transaction fail with aws neptune db

I was using gremlin-php with laravel-8.83.23 and aws neptune and I installed the driver as readme.md. When i send simple gremlin request, it works well until i start a transaction, the driver throw a serverException.
this is my code:

try {
            $db = new Connection([
                'host' => env('AWS_NEPTUNE_HOST'),
                'port' => env('AWS_NEPTUNE_PORT'),
                'ssl' => true,
                'graph' => 'graph',
            ]);
            $db->open();
            $db->message->registerSerializer('\Brightzone\GremlinDriver\Serializers\Gson3', TRUE);
            
            // this request works well
            $result = $db->send('g.V().count()');
            var_export($result);

            // when i start a transaction, exception occured
            $db->transactionStart();
            $db->send('g.addV("start").property(id, "node1").property("node_info", "{}").property("create_date", "2022-08-22")');
            $db->transactionStop();
            $res = $db->send('g.V().count()');
            var_dump($res);
            $db->close();
        } catch (\Exception $e) {
            $info = [
                'line' => $e->getLine(),
                'file' => $e->getFile(),
                'msg' => $e->getMessage(),
                'trace' => $e->getTrace()
            ];
            echo json_encode($info);
        }

the error msg is like this๏ผš

{"line":850,"file":"/var/www/laravel-app/vendor/brightzone/gremlin-php/src/Connection.php","msg":"The request message was parseable, but the arguments supplied in the message were in conflict or incomplete. Check the message format and retry the request. : {\"requestId\":\"2435eb21-39cd-4497-9a8b-d12ca7de95a5\",\"code\":\"MalformedQueryException\",\"detailedMessage\":\"Failed to interpret Gremlin query: Query parsing failed at line 1, character position at 1, error message : token recognition error at: 'rap'\"}\n\n ===================  SERVER TRACE  ========================= \narray (\n)\n ============================================================ \n","trace":[{"file":"/var/www/laravel-app/vendor/brightzone/gremlin-php/src/Connection.php","line":356,"function":"error","class":"Brightzone\\GremlinDriver\\Connection","type":"->","args":["{\"requestId\":\"2435eb21-39cd-4497-9a8b-d12ca7de95a5\",\"code\":\"MalformedQueryException\",\"detailedMessage\":\"Failed to interpret Gremlin query: Query parsing failed at line 1, character position at 1, error message : token recognition error at: 'rap'\"}\n\n ===================  SERVER TRACE  ========================= \narray (\n)\n ============================================================ \n",499]},{"file":"/var/www/laravel-app/vendor/brightzone/gremlin-php/src/Connection.php","line":508,"function":"socketGetUnpack","class":"Brightzone\\GremlinDriver\\Connection","type":"->","args":[]},{"function":"Brightzone\\GremlinDriver\\{closure}","class":"Brightzone\\GremlinDriver\\Connection","type":"->","args":[{"host":"neptune.xxx.amazonaws.com","port":"8182","username":null,"password":null,"graph":"graph","timeout":null,"message":{"configuration":{"op":"eval","processor":"session","requestUuid":"2435eb21-39cd-4497-9a8b-d12ca7de95a5"},"args":{"gremlin":"graph.tx().open()","session":"e338df0f-fb8d-46f9-9f73-b08e987e0f8c"}},"aliases":[],"emptySet":false,"ssl":true,"saslMechanism":"PLAIN","retryStrategy":"linear","retryAttempts":1},null,"","eval",[]]},{"file":"/var/www/laravel-app/vendor/brightzone/gremlin-php/src/Workload.php","line":80,"function":"call_user_func_array","args":[{},[{"host":"neptune.xxx.amazonaws.com","port":"8182","username":null,"password":null,"graph":"graph","timeout":null,"message":{"configuration":{"op":"eval","processor":"session","requestUuid":"2435eb21-39cd-4497-9a8b-d12ca7de95a5"},"args":{"gremlin":"graph.tx().open()","session":"e338df0f-fb8d-46f9-9f73-b08e987e0f8c"}},"aliases":[],"emptySet":false,"ssl":true,"saslMechanism":"PLAIN","retryStrategy":"linear","retryAttempts":1},null,"","eval",[]]]},{"file":"/var/www/laravel-app/vendor/brightzone/gremlin-php/src/Connection.php","line":511,"function":"linearRetry","class":"Brightzone\\GremlinDriver\\Workload","type":"->","args":[1]},{"file":"/var/www/laravel-app/vendor/brightzone/gremlin-php/src/Connection.php","line":608,"function":"send","class":"Brightzone\\GremlinDriver\\Connection","type":"->","args":[]},{"file":"/var/www/laravel-app/app/Http/Controllers/NeptuneController.php","line":24,"function":"transactionStart","class":"Brightzone\\GremlinDriver\\Connection","type":"->","args":[]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php","line":54,"function":"index","class":"App\\Http\\Controllers\\NeptuneController","type":"->","args":[]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php","line":45,"function":"callAction","class":"Illuminate\\Routing\\Controller","type":"->","args":["index",[]]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Route.php","line":262,"function":"dispatch","class":"Illuminate\\Routing\\ControllerDispatcher","type":"->","args":[{"uri":"api/nep","methods":["GET","HEAD"],"action":{"middleware":["api"],"uses":"App\\Http\\Controllers\\NeptuneController@index","controller":"App\\Http\\Controllers\\NeptuneController@index","namespace":null,"prefix":"api","where":[]},"isFallback":false,"controller":{},"defaults":[],"wheres":[],"parameters":[],"parameterNames":[],"computedMiddleware":["api"],"compiled":{}},{},"index"]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Route.php","line":205,"function":"runController","class":"Illuminate\\Routing\\Route","type":"->","args":[]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php","line":721,"function":"run","class":"Illuminate\\Routing\\Route","type":"->","args":[]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":128,"function":"Illuminate\\Routing\\{closure}","class":"Illuminate\\Routing\\Router","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php","line":50,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Routing\\Middleware\\SubstituteBindings","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php","line":127,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php","line":103,"function":"handleRequest","class":"Illuminate\\Routing\\Middleware\\ThrottleRequests","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{},[{"key":"a75f3f172bfb296f2e10cbfc6dfc1883","maxAttempts":60,"decayMinutes":1,"responseCallback":null}]]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php","line":55,"function":"handleRequestUsingNamedLimiter","class":"Illuminate\\Routing\\Middleware\\ThrottleRequests","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{},"api",{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Routing\\Middleware\\ThrottleRequests","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{},"api"]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":103,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php","line":723,"function":"then","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php","line":698,"function":"runRouteWithinStack","class":"Illuminate\\Routing\\Router","type":"->","args":[{"uri":"api/nep","methods":["GET","HEAD"],"action":{"middleware":["api"],"uses":"App\\Http\\Controllers\\NeptuneController@index","controller":"App\\Http\\Controllers\\NeptuneController@index","namespace":null,"prefix":"api","where":[]},"isFallback":false,"controller":{},"defaults":[],"wheres":[],"parameters":[],"parameterNames":[],"computedMiddleware":["api"],"compiled":{}},{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php","line":662,"function":"runRoute","class":"Illuminate\\Routing\\Router","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{"uri":"api/nep","methods":["GET","HEAD"],"action":{"middleware":["api"],"uses":"App\\Http\\Controllers\\NeptuneController@index","controller":"App\\Http\\Controllers\\NeptuneController@index","namespace":null,"prefix":"api","where":[]},"isFallback":false,"controller":{},"defaults":[],"wheres":[],"parameters":[],"parameterNames":[],"computedMiddleware":["api"],"compiled":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Routing/Router.php","line":651,"function":"dispatchToRoute","class":"Illuminate\\Routing\\Router","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php","line":167,"function":"dispatch","class":"Illuminate\\Routing\\Router","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":128,"function":"Illuminate\\Foundation\\Http\\{closure}","class":"Illuminate\\Foundation\\Http\\Kernel","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php","line":21,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php","line":31,"function":"handle","class":"Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php","line":21,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php","line":40,"function":"handle","class":"Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Foundation\\Http\\Middleware\\TrimStrings","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php","line":27,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php","line":86,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/fruitcake/laravel-cors/src/HandleCors.php","line":52,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Fruitcake\\Cors\\HandleCors","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php","line":39,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":167,"function":"handle","class":"Illuminate\\Http\\Middleware\\TrustProxies","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}},{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php","line":103,"function":"Illuminate\\Pipeline\\{closure}","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php","line":142,"function":"then","class":"Illuminate\\Pipeline\\Pipeline","type":"->","args":[{}]},{"file":"/var/www/laravel-app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php","line":111,"function":"sendRequestThroughRouter","class":"Illuminate\\Foundation\\Http\\Kernel","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/public/index.php","line":52,"function":"handle","class":"Illuminate\\Foundation\\Http\\Kernel","type":"->","args":[{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}]},{"file":"/var/www/laravel-app/server.php","line":21,"args":["/var/www/laravel-app/public/index.php"],"function":"require_once"}]}

how to fix this problem?

Having connectivity issues on two different cloud services

One is Compose (JanusGraph) and the other is Azure CosmosDB.
Configuring the connection array as instructed with SSL verifyPeer disabled and enabled. It always gives error.
Here's the script:

<?php

require_once('vendor/autoload.php');
use \Brightzone\GremlinDriver\Connection;

$db = new Connection([
	'host' => "zyx.composedb.com", 
	'port' => "18078",
//    	'graph' => 'mygraph', // tried both ways
//    	'ssl' => TRUE, // tried both ways
	'username' => 'admin',
    	'password' => 'secret',
	'ssl'      => [
                "ssl" => [
                    "verify_peer"      => FALSE,
                    "verify_peer_name" => FALSE,
                ],
            ],
]);
$db->message->registerSerializer('\Brightzone\GremlinDriver\Serializers\Gson3', TRUE); // tried without this as well
$db->open();
$result = $db->send('5+5');

The error I get:

PHP Warning:  Uncaught Brightzone\GremlinDriver\ServerException: The request attempted to access resources that the requesting user did not have access to. : Failed to authenticate

 ===================  SERVER TRACE  ========================= 
array (
)
 ============================================================ 
 in /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php:849
Stack trace:
#0 /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php(356): Brightzone\GremlinDriver\Connection->error('Failed to authe...', 401)
#1 /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php(507): Brightzone\GremlinDriver\Connection->socketGetUnpack()
#2 [internal function]: Brightzone\GremlinDriver\Connection->Brightzone\GremlinDriver\{closure}(Object(Brightzone\GremlinDriver\Connection), Object(Brightzone\GremlinDriver\Message), '', 'eval', Array)
#3 /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Workload.php(79): call_user_func_a in /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php on line 849

Warning: Uncaught Brightzone\GremlinDriver\ServerException: The request attempted to access resources that the requesting user did not have access to. : Failed to authenticate

 ===================  SERVER TRACE  ========================= 
array (
)
 ============================================================ 
 in /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php:849
Stack trace:
#0 /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php(356): Brightzone\GremlinDriver\Connection->error('Failed to authe...', 401)
#1 /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php(507): Brightzone\GremlinDriver\Connection->socketGetUnpack()
#2 [internal function]: Brightzone\GremlinDriver\Connection->Brightzone\GremlinDriver\{closure}(Object(Brightzone\GremlinDriver\Connection), Object(Brightzone\GremlinDriver\Message), '', 'eval', Array)
#3 /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Workload.php(79): call_user_func_a in /Users/esokullu/Code/test/gremlin/vendor/brightzone/gremlin-php/src/Connection.php on line 849

PHP7 Warnings on $db->send(...)

Hi all,

Using PHP 7.1.5 I'm experiencing warnings in the error_log as follows:

PHP Warning: Parameter 1 to Brightzone\GremlinDriver\Connection::Brightzone\GremlinDriver\{closure}() expected to be a reference, value given in [...]/vendor/brightzone/gremlin-php/src/Workload.php on line 78

These warnings seem to appear for every $db->send command, and thus there are quite a lot of them piling up in the log. Maybe someone has an idea on how to get rid of these (without changing the log level :-)

Adding Edge on 2 vertices causes an error

I get error with message: Brightzone\GremlinDriver\Connection::writeSocket: Could not write to socket every time i try to add an edge between 2 vertices.

Im using Azure Cosmos Gremlin API.

Note: i tried running the command directly to my graph database in azure cosmos and it works fine.

Driver connects to the server, but cannot find any data

Hello,

I'm quite new to Titan, but I really like it and currently trying to build the PHP app on it - so thank you for your driver :)

At the moment I run Titan 1.0 on Cassandra (all of the settings and configs - out of the box). I've populated the graph with data I needed and I succeed to get it through Gremlin console; but when I run even the simplest sample, like

require_once('vendor/autoload.php');
use \Brightzone\GremlinDriver\Connection;



$db = new Connection([
    'host' => 'localhost',
    'port' => 8182,
    'graph'=> 'graph'
]);

$db->open();
$query = "g.V()";
$result = $db->send($query);
var_dump($result);

I get a message that says "The server processed the request but there is no result to return (e.g. an {@link Iterator} with no elements)". Calculations queries (like $db->send("5+5")) works though, so I know that the connection is somehow correct; I suspect the graph name to be the issue - but don't know how to get the right one. I've tried to add 'standardtitangraph' (this is the instance name that's returned on graph creation in Gremlin console), 'tinkergraph', and even a full constructor that I pass to gremlin console to open a graph ('TitanFactory.open('../conf/titan-cassandra-es.properties')') - but none of them worked. I feel that I miss something really basic, but still - could you please help me with this one?

Thanks,
Gregory

What's the right configuration for Gremlin server?

What is the right .yaml configuration that I should use for the Gremlin server in order to connect the client?

I get an error

:> g.traversal().V(100).next()
WARN  org.apache.tinkerpop.gremlin.driver.MessageSerializer  - Response [PooledUnsafeDirectByteBuf(ridx: 30, widx: 30, cap: 30)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0.

SideEffects

I think that's not a problem, is a doubt.
I'm having trouble using sideEffect to update properties of a vertex.

I am running the following code:

$result = $connection->send("g.V(12360).sideEffect{it.name='Rodrigo'; it.idUser='10'}");

The error message:

A general server error occurred that prevented the request from being processed. : No such property: name for class: org.apache.tinkerpop.gremlin.process.traversal.traverser.O_Traverser >

This is the vertex contents:

{
  "data": [
    {
      "id": 12360,
      "label": "user",
      "type": "vertex",
      "properties": {
        "idUser": [
          {
            "id": "3yh-9jc-2dh",
            "value": "2"
          }
        ],
        "name": [
          {
            "id": "3k9-9jc-sl",
            "value": "Lacerda"
          }
        ]
      }
    }
  ]
}```

Warning when using transactionStop

Hi,

After calling transactionStop I get a warning in my gremlin server log "WARN org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler - Message with op code [close] is not recognized".

PHP Code:

$db->transactionStart();
$db->send($query)
$db->transactionStop(true);

Full trace:
[gremlin-server-worker-1] WARN org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler - Message with op code [close] is not recognized.
org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Message with op code [close] is not recognized.
at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.select(AbstractEvalOpProcessor.java:100)
at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:80)
at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:50)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:146)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)

Able to connect to db but $db->send('g.V()') gives 400 error no gremlin script supplied

Hi,

I apologize if this is the incorrect place to post such a question but it is hard to find a community for gremlin-php.

I am running running Janusgraph on Dynamo db with gremlin-server and am able to query from my web browser when I tunnel in and visit http://localhost?gremlin=g.V() but when I run:

require_once('vendor/autoload.php');
use \Brightzone\GremlinDriver\Connection;

$db = new Connection([
'host' => 'localhost',
'graph' => 'graph'
]);
$db->open();
$result = $db->send("g.v());
//do something with result
$db->close();

in a php script I get in my gremlin-server log:

1140300 [gremlin-server-worker-1] WARN org.apache.tinkerpop.gremlin.server.handler.HttpGremlinEndpointHandler - Invalid request - responding with 400 Bad Request and no gremlin script supplied

I have tried switching to WebSocketChannelizer but that just results in no activity on the gremlin-server at all.

Any help would be greatly appreciated.

Regards,

Robbie

Cant receive data

Hello,

I can not run the sample code, the following error appears :
Notice: Undefined offset: 1 in /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php on line 211

Warning: unpack(): Type C: not enough input, need 1, have 0 in /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php on line 214

Warning: array_values() expects parameter 1 to be array, boolean given in /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php on line 214

Fatal error: Uncaught exception 'brightzone\rexpro\ServerException' with message 'A general server error occurred that prevented the request from being processed. : Empty reply. Most likely the result of an irregular request. (Check custom Meta, or lack of in the case of a non-isolated query)' in /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php:620 Stack trace: #0 /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php(268): brightzone\rexpro\Connection->error('Empty reply. Mo...', 500) #1 /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php(358): brightzone\rexpro\Connection->socketGetUnpack() #2 /var/www/html/gremlin/index.php(11): brightzone\rexpro\Connection->send() #3 {main} thrown in /var/www/html/gremlin/vendor/brightzone/gremlin-php/src/Connection.php on line 620

My code:
require_once('vendor/autoload.php');
use \brightzone\rexpro\Connection;

$db = new Connection;
$db->open('localhost', 'graph');
$db->message->gremlin = '100-1';
$db->send();
$db->close();

I'm with the 0.9.0 -M2 version with Titan 0.9.0 and 3.0.0 Gremlin .

Rework Error management

Some of the current issues:

  • Improper bubbling of stack traces for InternalExceptions
  • Incomplete testing of errors.
    • Some extra tests need to be added for some errors
    • Current tests need to check the error type and message
  • Use different error codes for InternalExceptions (they all currently use 500). Will need to check if any other codes would be more appropriate.

valueMap(true) fails to serialize

The command works fine in the gremlin console, but fails to serialize when returned.

Command: g.V().limit(1).valueMap(true)

Expected Return: {label=User, id=someid123, count=1}

Actual Error Returned:

gremlin-php driver has thrown the following error : 
Item type 'g:T' is not currently supported by the serializer
(Brightzone\GremlinDriver\Serializers\Gson3)

The value of $item passed into deconvert that it fails on is:

array(2) {
  ["@type"]=>
  string(3) "g:T"
  ["@value"]=>
  string(5) "label"
}

g:T is also the type for id.

g.V()limit(1).valueMap() works fine through gremlin-php and console, just not with the true (which is supposed to include the id and label instead of just properties).

I couldn't connect to OrientDB

Hi for orientDB connection i tried several connection string but non of them worked.

$db->open('localhost:2480/command/GratefulDeadConcerts/gremlin/', 'g','root','pass');

$db->open('localhost:2480/', 'g','root','pass');

$db->open('localhost:2480/command/', 'g','root','pass');

...

TitanFactory.open with conf file

Any help on how I would open an existing graph from an AWS DynamoDB. In gremlin I use

graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties")

The connection through this class selects a default graph instance. Thanks!

Connection Error in Connection.php

Hi Team,

Azure Web App, Azure CosmosDB (Gremlin), Tried on 5.6, 7.0, 7.1

Any suggestions, error isn't particularly helpful.

Config as:

$db = new Connection([
  'host' => 'MYDB.graphs.azure.com',
  'port' => 443,
  'graph' => 'graph',
  'username' => '/dbs/MYDB/colls/MYCOL',
  'password' => 'ReallyImportantStuff',
  'ssl' => [
    "ssl"=> [
        "cafile" => "%ProgramFiles(x86)%\Git\bin\curl-ca-bundle.crt",
        "verify_peer"=> true,
        "verify_peer_name"=> true,
    ]
]
]);

Returns:

Fatal error: Uncaught exception 'Brightzone\GremlinDriver\InternalException' with message 'gremlin-php driver has thrown the following error : ' in D:\home\site\wwwroot\vendor\brightzone\gremlin-php\src\Connection.php:791
Stack trace:
#0 D:\home\site\wwwroot\vendor\brightzone\gremlin-php\src\Connection.php(373): Brightzone\GremlinDriver\Connection->error('', 0, true)
#1 D:\home\site\wwwroot\vendor\brightzone\gremlin-php\src\Connection.php(153): Brightzone\GremlinDriver\Connection->connectSocket()
#2 D:\home\site\wwwroot\index.php(26): Brightzone\GremlinDriver\Connection->open()
#3 {main}
  thrown in D:\home\site\wwwroot\vendor\brightzone\gremlin-php\src\Connection.php on line 791

Cannot Try Catch DB->Connection->Open

        try {
            $db->open();
        } catch (\Brightzone\GremlinDriver\InternalException $e) {
            $error_message = $e->getMessage());
        }

This command fails to catch the thrown exception.

Tested on PHP 7.1+

Further debugging shows the error occurs https://github.com/PommeVerte/gremlin-php/blob/master/src/Connection.php#L370-L377

at command $this->_socket = @stream_socket_client ...

Setting this to a variable first fixes it, will submit a PR shortly but would love an explanation from those who know why :)

        $fp = @stream_socket_client(
                                    $protocol. '://' . $this->host .':'.$this->port,
                                    $errno,
                                    $errorMessage,
                                    $this->timeout ? $this->timeout : ini_get("default_socket_timeout"),
                                    STREAM_CLIENT_CONNECT,
                                    $context
                                    );

        if(!$fp){
            $this->error($errorMessage, $errno, TRUE);
        }

        $this->_socket = $fp;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.