gremlinclient icon indicating copy to clipboard operation
gremlinclient copied to clipboard

Message decoding check required.

Open vivekr20 opened this issue 8 years ago • 5 comments

https://github.com/davebshow/gremlinclient/blob/445677732400eab0d1d8a1c6006981a26527b0e2/gremlinclient/connection.py#L319

If the underlying WebSocket response message is already decoded, this call breaks. Ideally, there should be a check to accommodate this. Maybe assume already decoded if this line throws?

vivekr20 avatar Sep 11 '17 20:09 vivekr20

This might do the trick:

try: message = json.loads(result.decode("utf-8")) except AttributeError as e: message = json.loads(result)

vivekr20 avatar Sep 11 '17 21:09 vivekr20

Hi @vivekr20. I'm curious about this issue. Does the Gremlin Server ever return a message that isn't bytes? Have you seen an error here? If so, could you post code to reproduce it?

Also, as a side note, this project is basically inactive. Instead, I would recommend that you use either aiogremlin, Goblin, or the official gremlinpython.

davebshow avatar Sep 13 '17 16:09 davebshow

Hi David,

Thank you for your response. I think It really depends on how the server chooses to send data over WebSocket? I’ve been working on Cosmos DB’s Gremlin Server, and if I configure the server to send data as String over WebSocket, I get the below error:

“AttributeError("'str' object has no attribute'decode'”

Full Call Stack: “ ERROR:tornado.application:Exception in callback functools.partial(<function wrap..null_wrapper at 0x0000025B97449AE8>, <tornado.concurrent.F uture object at 0x0000025B97438E48>) Traceback (most recent call last): File "C:\Program Files\Python36\lib\site-packages\tornado\ioloop.py", line 600, in _run_callback ret = callback() File "C:\Program Files\Python36\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper return fn(*args, **kwargs) File "C:\Program Files\Python36\lib\site-packages\gremlinclient\connection.py", line 319, in parser message = json.loads(result.decode("utf-8")) AttributeError: 'str' object has no attribute 'decode' ”

Thanks for the pointers to the other clients BTW. I’m trying to build better compatibility for Cosmos DB’s gremlin API with Python client drivers, so the pointers will help! ☺ To start with, I want to build a few “hello world” samples for connecting to cosmos DB’s gremlin API using the one’s mentioned below. Could I reach out to you later, if I have any issues with working these client drivers?

Thanks, Vivek

From: David Michael Brown [mailto:[email protected]] Sent: Wednesday, September 13, 2017 9:35 AM To: davebshow/gremlinclient [email protected] Cc: Vivek Ravindran (COSMOS DB) [email protected]; Mention [email protected] Subject: Re: [davebshow/gremlinclient] Message decoding check required. (#14)

Hi @vivekr20https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fvivekr20&data=02%7C01%7Cvivekra%40microsoft.com%7C59adb60f362c435959e808d4fac56f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636409173262964822&sdata=zoHbk%2F6ljMz3BmnzNTg0TLitWHVV1hFxRInN35iEK7M%3D&reserved=0. I'm curious about this issue. Does the Gremlin Server ever return a message that isn't bytes? Have you seen an error here? If so, could you post code to reproduce it?

Also, as a side note, this project is basically inactive. Instead, I would recommend that you use either aiogremlin, Goblin, or the official gremlinpython.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdavebshow%2Fgremlinclient%2Fissues%2F14%23issuecomment-329224844&data=02%7C01%7Cvivekra%40microsoft.com%7C59adb60f362c435959e808d4fac56f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636409173262964822&sdata=ou%2FedY9vrCMg1wEbKfcIACKDv7NXnB14uzbeWpk9t%2BY%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAKT6bxygmH8YXBoFhZETDl9qy0lTHCKSks5siARLgaJpZM4PTw1U&data=02%7C01%7Cvivekra%40microsoft.com%7C59adb60f362c435959e808d4fac56f0a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636409173262964822&sdata=bRUg3diQV2fen4v2InInVsLtekFkP99QooYDHEf%2Bvbo%3D&reserved=0.

vivekr20 avatar Sep 13 '17 17:09 vivekr20

I would be happy to help you with anything related to the Python TinkerPop libraries. I would also love to see examples with CosmosDB. Please ping me with a link if you get anything up.

davebshow avatar Sep 13 '17 19:09 davebshow

That would be greatly appreciated :) Will do!

vivekr20 avatar Sep 13 '17 19:09 vivekr20