"Connection reset by peer" when using pyTigerGraph

Sorry, just starting out with TG… and pyTigerGraph. I’ve built the sample person-friend graph using the GQSL command line. Now, I’m trying this on my local machine to try to talk to my remote Azure TG DB based on this pyTigerGraph/GSQL101 - PyTigerGraph.ipynb at master · pyTigerGraph/pyTigerGraph · GitHub

I also don’t understand much about security but the file tigergraph_key.pem does exist (and I know enough to keep it secret!)

import pyTigerGraph as tg
graph = tg.TigerGraphConnection(
    host = 'http://X.X.X.X', # hiding exact IP
    graphname="social",
    username='tigergraph',
    password='tigergraph'
)
graph.getEndpoints() # returns a lot of stuff
graph.getVertices('person')  # returns persons from the example data
graph.getEdgeTypes() # returns ['friendship']
graph.getVertexCount('person') # returns 7
graph.getVersion() # returns release_3.0.5_09-05-2020

BUT when I try this,

graph.initGsql(certLocation=‘tigergraph_key.pem’)

I get “Connection reset by peer” (after waiting a bit.)

I’m not sure what noob mistake I’m making…

My configuration on (Virtual Machine on remote Azure)
TigerGraph Developer version release_3.0.5_09-05-2020
I’ve opened up the ports 9000 and 14240, so I can see the example DB in Graph Studio
Ubuntu 18.04.5 LTS
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2

Also…
If I login remotely and use host=‘127.0.0.1’ and then do:
graph.initGsql()

I get “Connection refused”

Thanks in advance.

1 Like

@clemwang , you’re doing everything the right way :slight_smile: except the initGSQL , I assume you’re willing to run GSQL queries for that you just do :

result = graph.gsql("<your query>")
Example :
query_multiline = """
USE GRAPH MyGraph
ls 
"""
 
result = graph.gsql(query_multiline) 

That didn’t work. I still get ConnectionResetError: [Errno 54] Connection reset by peer

My suspicion is that I didn’t set up something correctly with security.

I should have added the Python traceback:

---------------------------------------------------------------------------
ConnectionResetError                      Traceback (most recent call last)
<ipython-input-88-61ab3538d904> in <module>
      4 """
      5 
----> 6 result = graph.gsql(query_multiline)
      7 

~/3.7/lib/python3.8/site-packages/pyTigerGraph/pyTigerGraph.py in gsql(self, query, options)
   1606         """
   1607         if not self.gsqlInitiated:
-> 1608             self.gsqlInitiated = self.initGsql()
   1609         if self.gsqlInitiated:
   1610             if "\n" not in query:

~/3.7/lib/python3.8/site-packages/pyTigerGraph/pyTigerGraph.py in initGsql(self, certLocation)
   1566         if self.downloadCert:  # HTTP/HTTPS
   1567             import ssl
-> 1568             Res = ssl.get_server_certificate((sslhost, 443))
   1569             # print(Res)
   1570             try:

/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py in get_server_certificate(addr, ssl_version, ca_certs)
   1482                                      cafile=ca_certs)
   1483     with  create_connection(addr) as sock:
-> 1484         with context.wrap_socket(sock) as sslsock:
   1485             dercert = sslsock.getpeercert(True)
   1486     return DER_cert_to_PEM_cert(dercert)

/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

ConnectionResetError: [Errno 54] Connection reset by peer

Thanks for the reply please update your code as per below

graph = tg.TigerGraphConnection(
    host = 'http://X.X.X.X', # hiding exact IP
    graphname="social",
    username='tigergraph',
    password='tigergraph',
    useCert=False
)

Your tigergraph box is not ssl

2 Likes

Aha! The missing parameter was useCert=False which fixes everything!

Thanks!!!

1 Like