Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PubSub response parsing on JSON output #499

Closed
dmvass opened this issue Oct 14, 2019 · 3 comments
Closed

PubSub response parsing on JSON output #499

dmvass opened this issue Oct 14, 2019 · 3 comments

Comments

@dmvass
Copy link

dmvass commented Oct 14, 2019

Hi @tidwall! Can you please suggest the proper way for parsing pubsub messages on JSON output, in the telnet messages are not have a length prefix or CRLF.

telnet localhost 9851
Trying ::1...
Connected to localhost.
Escape character is '^]'.
OUTPUT json
$31
{"ok":true,"elapsed":"40.9µs"}
subscribe warehouse
{"ok":true,"command":"subscribe","channel":"warehouse","num":1,"elapsed":"73.7µs"}{"command":"set","group":"5da490312471ae00015fa4a2","detect":"inside","hook":"warehouse","key":"fleet","time":"2019-10-14T16:24:08.9040845Z","id":"bus","object":{"type":"Point","coordinates":[-112.26034343,33.46]}}{"command":"set","group":"5da490312471ae00015fa4a2","detect":"inside","hook":"warehouse","key":"fleet","time":"2019-10-14T16:24:10.0358781Z","id":"bus","object":{"type":"Point","coordinates":[-112.26034343,33.46]}}{"command":"set","group":"5da490312471ae00015fa4a2","detect":"inside","hook":"warehouse","key":"fleet","time":"2019-10-14T16:24:10.7501405Z","id":"bus","object":{"type":"Point","coordinates":[-112.26034343,33.46]}}{"command":"set","group":"5da490312471ae00015fa4a2","detect":"inside","hook":"warehouse","key":"fleet","time":"2019-10-14T16:24:11.4309711Z","id":"bus","object":{"type":"Point","coordinates":[-112.26034343,33.46]}}
@tidwall
Copy link
Owner

tidwall commented Oct 16, 2019

I don't recommend using OUTPUT json with PubSub. All geofence are in JSON already.
It's best to use a standard Redis client. They all support PubSub.

If you must use telnet then simply issuing a SUBSCRIBE warehouse, without the OUTPUT command, will give you a better response.

@dmvass
Copy link
Author

dmvass commented Oct 16, 2019

Agree with you but why the server provides a different OUTPUT json contract for commands and PubSub?

@dmvass dmvass closed this as completed Oct 25, 2019
tidwall added a commit that referenced this issue Oct 28, 2019
This commit fixes a bug that causes bad formatting for geofence
notifications when a client's output is set to JSON.

closes #499
@tidwall
Copy link
Owner

tidwall commented Oct 28, 2019

I just fixed the bad formatting for JSON PubSub. Thanks for letting me know.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants