Closed 070hm closed 4 months ago
Hello @070hm
Did you set websocket subprotocol to centrifuge-protobuf
, like for example in centrifuge-java:
Another possible reason is that you need to send varint-length encoded Protobuf messages - see in centrifuge-java: https://github.com/centrifugal/centrifuge-java/blob/b2dc056b2813807d88ad473d679bffbe98ae98d6/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Client.java#L523 - i.e. each protobuf command must be prepended by its length. Don't forget that client protocol WebSocket frame may contain several messages: length - message - length - message
Hello @070hm
Did you set websocket subprotocol to
centrifuge-protobuf
, like for example in centrifuge-java:
Thanks for your quick response! I have already set the WebSocket protocol to centrifuge-protobuf.
Another possible reason is that you need to send varint-length encoded Protobuf messages - see in centrifuge-java: https://github.com/centrifugal/centrifuge-java/blob/b2dc056b2813807d88ad473d679bffbe98ae98d6/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Client.java#L523 - i.e. each protobuf command must be prepended by its length. Don't forget that client protocol WebSocket frame may contain several messages: length - message - length - message
I will double-check that and give it another try,
Another possible reason is that you need to send varint-length encoded Protobuf messages - see in centrifuge-java: https://github.com/centrifugal/centrifuge-java/blob/b2dc056b2813807d88ad473d679bffbe98ae98d6/centrifuge/src/main/java/io/github/centrifugal/centrifuge/Client.java#L523 - i.e. each protobuf command must be prepended by its length. Don't forget that client protocol WebSocket frame may contain several messages: length - message - length - message
@FZambia
Thanks, bro! I solved the issue by structuring the bytes like this:length - message
. Is this solution for sending multiple command messages at the same time? and is same with reply message ?
Is this solution for sending multiple command messages at the same time? and is same with reply message ?
Yes, it's described a bit here – https://centrifugal.dev/docs/transports/client_protocol#top-level-batching
It's up to you whether your SDK will combine multiple commands into one websocket frame when sending from client to server, but it's necessary to support multiple replies in one WS frame coming from server to client – Centrifugo often automatically combines pushes/replies issued closely to each other.
Is this solution for sending multiple command messages at the same time? and is same with reply message ?
Yes, it's described a bit here – https://centrifugal.dev/docs/transports/client_protocol#top-level-batching
It's up to you whether your SDK will combine multiple commands into one websocket frame when sending from client to server, but it's necessary to support multiple replies in one WS frame coming from server to client – Centrifugo often automatically combines pushes/replies issued closely to each other.
Thanks for the explanation. You have a great project, and you're truly solving real problems. Keep up the excellent work.
Hi centrifugo team
We are internally developing a client SDK for Centrifugo using Kotlin Multiplatform technology. Inshallah, once we complete the development, we will share the library as open-source. However, when we started sending command protocols to the server, we encountered an issue on the server side.
2024-06-30T19:19:37Z INF error reading command | client=a436b97f-d491-4943-a24b-8646711a41f3 error=proto: Command: illegal tag 0 (wire type 1) user=
It seems we have an issue with the serialization method of the command client protocol. Here is a snippet of the code in our clientWe serialize the command to a byte array in the Centrifugo Java client, while the command is serialized to a ByteString. We are unsure why we are encountering the following error from the backend: error=proto: Command: illegal tag 0 (wire type 1) user=. Is there something missing in the Command message?
Note: