[Errno 111] Connection refused. while Connecting to orientdb using pyorient

674 views
Skip to first unread message

Learner

unread,
May 11, 2016, 3:35:29 AM5/11/16
to OrientDB
Hi All,

I am trying to connect/open orientdb using pyorient.
However both connect and open give
PyOrientConnectionException: Socket Error: [Errno 111] Connection refused.
Do I need to open up any port explicitly ?

I am able to connect to orientdb from orientdb console.

orientdb> connect remote:localhost/testdb admin admin
Connecting to database [remote:localhost/testdb] with user 'admin'...OK

In [1]: import pyorient
In [2]: client = pyorient.OrientDB("localhost", 2424)
In [3]: client.set_session_token(True)
Out[3]: <pyorient.orient.OrientDB object at 0xc04610>
In [4]: session_id = client.connect("admin", "admin")
---------------------------------------------------------------------------
PyOrientConnectionException               Traceback (most recent call last)

/home/admin/<ipython console> in <module>()

/home/admin/pyorient/orient.pyc in connect(self, user, password, client_id, serialization_type)
    290
    291         '''
--> 292         return self.get_message("ConnectMessage") \
    293             .prepare((user, password, client_id, serialization_type)).send().fetch_response()
    294

/home/admin/pyorient/orient.pyc in get_message(self, command)
    487                     token = self._auth_token
    488
--> 489                 message_instance = _Message(self._connection)\
    490                     .set_session_token(token)
    491                 message_instance._push_callback = self._push_received

/home/admin/pyorient/messages/connection.pyc in __init__(self, _orient_socket)
     15
     16     def __init__(self, _orient_socket):
---> 17         super( ConnectMessage, self ).__init__(_orient_socket)
     18
     19         self._user = ''

/home/admin/pyorient/messages/base.pyc in __init__(self, sock)
     22         :type sock: OrientSocket
     23         """
---> 24         sock.get_connection()
     25         self._orientSocket = sock
     26         self._protocol = self._orientSocket.protocol

/home/admin/pyorient/orient.pyc in get_connection(self)
     50     def get_connection(self):
     51         if not self.connected:
---> 52             self.connect()
     53
     54         return self._socket

/home/admin/pyorient/orient.pyc in connect(self)
     80         except socket.error as e:
     81             self.connected = False
---> 82             raise PyOrientConnectionException( "Socket Error: %s" % e, [] )
     83
     84     def close(self):

PyOrientConnectionException: Socket Error: [Errno 111] Connection refused

In [5]: client.db_open( "testdb", "admin", "admin" )

---------------------------------------------------------------------------
PyOrientConnectionException               Traceback (most recent call last)

/home/admin/<ipython console> in <module>()

/home/admin/pyorient/orient.pyc in db_open(self, db_name, user, password, db_type, client_id)
    376         '''
    377
--> 378         info, clusters, nodes = self.get_message("DbOpenMessage") \
    379             .prepare((db_name, user, password, db_type, client_id)).send().fetch_response()
    380

/home/admin/pyorient/orient.pyc in get_message(self, command)
    487                     token = self._auth_token
    488
--> 489                 message_instance = _Message(self._connection)\
    490                     .set_session_token(token)
    491                 message_instance._push_callback = self._push_received

/home/admin/pyorient/messages/database.pyc in __init__(self, _orient_socket)
     45 class DbOpenMessage(BaseMessage):
     46     def __init__(self, _orient_socket):
---> 47         super(DbOpenMessage, self).__init__(_orient_socket)
     48
     49         self._user = ''

/home/admin/pyorient/messages/base.pyc in __init__(self, sock)
     22         :type sock: OrientSocket
     23         """
---> 24         sock.get_connection()
     25         self._orientSocket = sock
     26         self._protocol = self._orientSocket.protocol

/home/admin/pyorient/orient.pyc in get_connection(self)
     50     def get_connection(self):
     51         if not self.connected:
---> 52             self.connect()
     53
     54         return self._socket

/home/admin/pyorient/orient.pyc in connect(self)
     80         except socket.error as e:
     81             self.connected = False
---> 82             raise PyOrientConnectionException( "Socket Error: %s" % e, [] )
     83
     84     def close(self):

PyOrientConnectionException: Socket Error: [Errno 111] Connection refused

alessand...@gmail.com

unread,
May 11, 2016, 4:45:15 AM5/11/16
to OrientDB
Hi Lerner, 
I launched the server and I tried this code

import pyorient

db_name
='python_test'

print("connection to the server...")
client
=pyorient.OrientDB("localhost",2424)
client
.set_session_token(True)
session_id
=client.connect("root","root")
print("OK - sessionID: ",session_id,"\n")

client
.db_open( db_name, "root", "root" )
client
.db_close()

and it works for me.

Learner

unread,
May 11, 2016, 9:08:48 AM5/11/16
to OrientDB
Hi Alessand,

Thanks for replying.

Can you tell me how are you launching the server.
In my case I am launching it using sv utility "exec chpst -u $ORIENTDB_USER $ORIENTDB_DIR/bin/server.sh $DISTRIBUTED".

It shows up in ps output as follows:-
root       299  0.0  0.0   4844   336 ?        Ss   May10   0:00 runsv orientdb

I see 2424 is in listen state:-
:/home/admin# netstat -tulpn | grep 2424
tcp        0      0 0.0.0.0:2424            0.0.0.0:*               LISTEN      309/java 

PID for port 2424/tcp is 309:
:/home/admin# fuser 2424/tcp
309

This pid maps to orientd:
:/home/admin# pwdx 309
309: /var/lib/orientdb/bin
:/home/admin#

Is there any config I need to tweak or check ?

alessand...@gmail.com

unread,
May 11, 2016, 9:31:34 AM5/11/16
to OrientDB
Hi Learner,
I launched it from terminal with this command sh mypath/bin/server.sh

Best regards,
Alessandro. 
Reply all
Reply to author
Forward
0 new messages