Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Strictly define how JSONs are separated in GRPC gateway #11372

Open
socketpair opened this issue Nov 19, 2019 · 29 comments
Open

Strictly define how JSONs are separated in GRPC gateway #11372

socketpair opened this issue Nov 19, 2019 · 29 comments

Comments

@socketpair
Copy link

socketpair commented Nov 19, 2019

I use GRPC gateway to access etcd watching functionality. Namely, https://github.com/etcd-io/etcd/blob/master/Documentation/dev-guide/api_grpc_gateway.md#watch-keys .

But I don't have any specifications on how should I separate JSONs in the response stream since it is not documented anywhere.

Basically I have 3 ways:

  1. HTTP chunk = message
    This fails at least in Fedora 31 on high load because sometimes bare newline \n appears as a separate chunk. In order to fix you probably should first concatenate JSON with \n before calling to Write(). Also, intermediate proxies may re-chunk stream.

  2. Messages are separated using strictly one newline.
    It is not documented as well, and comment in GRPC gateway states that newline is added just to simplify debugging. Somewhere in the net, I found that other software uses a double newline for that purpose (allow to divide messages containing formatted JSON). Currently, I choose this way.

  3. Use JSON finite state machine to detect end of a message.
    This way will work in any case, but technically this requires additional libraries for the majority of programming languages.

So, Please strictly document exact behavior (protocol) which should be considered for implementing JSON stream parser.

Original issue:
grpc-ecosystem/grpc-gateway#1086

@stale
Copy link

stale bot commented Apr 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 6, 2020
@socketpair
Copy link
Author

Hay! It's still actual

@stale stale bot removed the stale label Apr 6, 2020
@stale
Copy link

stale bot commented Jul 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 5, 2020
@socketpair
Copy link
Author

BUMP. Still actual.

@stale stale bot removed the stale label Jul 6, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 4, 2020
@socketpair
Copy link
Author

It is still actual!

@stale stale bot removed the stale label Oct 4, 2020
@stale
Copy link

stale bot commented Jan 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 2, 2021
@socketpair
Copy link
Author

No, it's not stale

@stale stale bot removed the stale label Jan 2, 2021
@stale
Copy link

stale bot commented Apr 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 3, 2021
@socketpair
Copy link
Author

No, it's not stale

@stale stale bot removed the stale label Apr 4, 2021
@stale
Copy link

stale bot commented Jul 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 3, 2021
@socketpair
Copy link
Author

It's actual

@stale stale bot removed the stale label Jul 3, 2021
@stale
Copy link

stale bot commented Oct 1, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 1, 2021
@socketpair
Copy link
Author

Still actual

@stale stale bot removed the stale label Oct 3, 2021
@stale
Copy link

stale bot commented Jan 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 1, 2022
@socketpair
Copy link
Author

Still

@stale stale bot removed the stale label Jan 1, 2022
@nic-6443
Copy link

nic-6443 commented Feb 27, 2022

We encountered the same problem, as there is no clear way to split messages, resulting in the client not being able to handle receiving partial messages or multiple messages in one HTTP chunk when ETCD is proxied by an HTTP server like nginx.

@nic-6443
Copy link

nic-6443 commented Feb 27, 2022

Special attention needs to be paid to ETCD v3.3.0, because of a bug in grpc-gateway v1.3.0(ETCD v3.3.0 depended on), the way of using newlines as separators will fail.
See:

@socketpair
Copy link
Author

Happily I switched to websocket transport.

@stale
Copy link

stale bot commented Jun 12, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 12, 2022
@socketpair
Copy link
Author

Still actual.

@stale stale bot removed the stale label Jun 13, 2022
@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2022
@socketpair
Copy link
Author

Bump

@stale stale bot removed the stale label Sep 21, 2022
@stale
Copy link

stale bot commented Dec 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 31, 2022
@socketpair
Copy link
Author

.

@stale stale bot removed the stale label Jan 1, 2023
@stale
Copy link

stale bot commented Apr 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 2, 2023
@socketpair
Copy link
Author

.

@stale stale bot removed the stale label Apr 2, 2023
@stale
Copy link

stale bot commented Aug 12, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@socketpair
Copy link
Author

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants