Discussion Forum

GRPC Fails to Connect with Python Flask

Incompatibility Between Python GRPC and Python Flask: I have a single page python function that runs a query on Grakn 1.6.2 using the latest Grakn Python client, and it works fine. I have a basic 2 page Python Flask webserver that also works fine. However, when I bring the Grakn query program into the Python Flask environment it will not execute and returns a GRPC Connect Failed error, shown below. I have tested it on clean directories, with the minimum code three times, and the same error is returned each time.

grakn.exception.GraknError.GraknError: Could not obtain sessionId for keyspace "pm_2", stems from: <_Rendezvous of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "Connect Failed"
        debug_error_string = "{"created":"@1588678350.715000000","description":"Failed to create subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":2721,"referenced_errors":[{"created":"@1588678350.713000000","description":"Pick Cancelled","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":241,"referenced_errors":[{"created":"@1588678350.713000000","description":"Connect Failed","file":"src/core/ext/filters/client_channel/subchannel.cc","file_line":689,"grpc_status":14,"referenced_errors":[{"created":"@1588678350.713000000","description":"OS Error","file":"src/core/lib/iomgr/tcp_client_windows.cc","file_line":106,"os_error":"No connection could be made because the target machine actively refused it.\r\n","syscall":"ConnectEx","wsa_error":10061}]}]}]}"```

The Flask webserver expects a port connection on port 5000, the grakn grpc on port 48555. Looking into StackOverflow with similar issues on TensorFlow, the problem appears to be ports. Any ideas??? Are webservers incompatible with Grakn client GRPC? Basic code is added below, just use pipenv install. You can use flask run to start the web server.

The gquery file will work perfectly until you have run the web server, once this has been done, the grpc connection will failG-D3.zip (17.8 KB)

Hi Modeller!

By latest, did you mean you’re using ‘Client Python’ version 1.7.0 to work with Grakn Core 1.6.2?

We’ve got a table where we say Grakn Core 1.6.2 is best used with Client Python 1.6.1.

I’m not sure if it’s the problem here, but for the sake of reducing variability during the troubleshooting process, do you think you can setup another example where we use Client Python 1.6.1 with Grakn Core 1.6.2?

That would help us narrow down the problem and simplify the troubleshooting process.