_MultiThreadedRendezvous with the debug_error_string = "None"
Problem Statement
I'm implementing a gRPC communication service between the Java application (spring-boot as a backend service) and the Python application (Django as a middleware). A huge volume of the data is available in the Mongo database and is connected to the spring application, from which I want to retrieve the data, and perform the CRUD operations, using the gRPC framework, therefore, the spring application works as a service provider in gRPC callbacks. On the client side of the gRPC framework, i.e. on Django output, I need the data to be available in JSON format so that the data can be passed to another frontend application where the user can interact with the dashboard.
The Error Message
After running the Django application, this is the error message displayed on the method call.
Request Method: GET
Request URL: http://127.0.0.1:8000/api/info/
Django Version: 4.1
Exception Type: _MultiThreadedRendezvous
Exception Value:
<_MultiThreadedRendezvous of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Exception deserializing response!"
debug_error_string = "None"
>
Exception Location: /Users/Bhavesh/Codebase/gsoc-smiles/grpc_listener/venv/lib/python3.9/site-packages/grpc/_channel.py, line 826, in _next
Raised during: client.views.client
Python Executable: /Users/Bhavesh/Codebase/gsoc-smiles/grpc_listener/venv/bin/python
Python Version: 3.9.12
Python Path:
['/Users/Bhavesh/Codebase/gsoc-smiles/grpc_listener',
'/opt/anaconda3/lib/python39.zip',
'/opt/anaconda3/lib/python3.9',
'/opt/anaconda3/lib/python3.9/lib-dynload',
'/Users/Bhavesh/Codebase/gsoc-smiles/grpc_listener/venv/lib/python3.9/site-packages']
Server time: Sun, 28 Aug 2022 23:45:40 +0000
gRPC protobuf
syntax = "proto3";
package calcInfo;
message CalcInfo{
string calcinfo_id = 1;
string smiles = 2;
int64 nbasis = 3;
int64 nmo = 4;
int64 nalpha = 5;
int64 nbeta = 6;
int64 natom = 7;
double energy = 8;
}
message ListInfoRequest {}
message ListInfoResponse {
CalcInfo calcInfo = 1;
}
service CalcInfoService {
rpc ListCalcInfo (ListInfoRequest) returns (stream CalcInfo) {};
}
The gRPC client implementation (Django).
The below code refers implementation of the LIST ALL operation in the view.py file.
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse, JsonResponse
import time
import grpc
import json
import calc_info_pb2, calc_info_pb2_grpc
def listCalcInfo(channel):
stub = calc_info_pb2_grpc.CalcInfoServiceStub(channel)
for info_list in stub.ListCalcInfo(calc_info_pb2.ListInfoRequest()):
data = {'calcinof_id':info_list.calcinfo_id,
'smiles':info_list.smiles,
'nbasis':info_list.nbasis,
'nmo':info_list.nmo,
'nalpha':info_list.nalpha,
'nbeta':info_list.nbeta,
'natom':info_list.natom,
'energy':info_list.energy}
return json.dumps(data)
@csrf_exempt
def client(request):
if request.method == 'GET':
print(request)
with grpc.insecure_channel('localhost:50051') as channel:
return JsonResponse(listCalcInfo(channel), safe=False)
# return JsonResponse(json.dumps(data), safe=False)
The gRPC server implementation (Spring boot)
@Override
public void listCalcInfo(ListInfoRequest request, StreamObserver<ListInfoResponse> responseObserver) {
System.out.println(" \n\n ----------- LIST OPERATION ---------- ");
System.out.println("Received a request to LIST the Info data.");
// Searching for the data from mongo collection (iteration: document by document)
mongoCollection.find().iterator().forEachRemaining(document -> responseObserver.onNext(
ListInfoResponse.newBuilder()
.setCalcInfo(documentToCalcInfo(document)).build()
));
System.out.println("Successfully displayed the Info Data from Mongo Collection");
System.out.println("----------------------------------------");
super.listCalcInfo(request, responseObserver);
}