-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
6.10 protobuf.js decode failed #553
Comments
Haven't looked over this in detail, but maybe related: https://github.com/dcodeIO/protobuf.js/wiki/How-to-read-binary-data-in-the-browser-or-under-node.js%3F |
Indeed, but I failed !
Js client XHR.response is ArrayBuffer type, but content is { } . Or I where do wrong ? Thanks a lot! |
I haven't used the php library myself, unfortunately. Isn't there a safer way to work with buffers in PHP, instead of converting hence and forth from/to strings? String conversion often results in corrupted data due to the underlying encoding used (i.e. utf8, utf16le). |
JS client change code
I tried a lot of methods Thanks a lot! |
On the PHP side, you have to make sure that it outputs proper binary data. Then, using |
Thanks for your reply ! |
You are welcome! Feel free to reopen when necessary. |
Hello
My server is PHP, use google protobuf php lib, client use protobuf.js. use http post method .
Php server return protobuf encode string data, client receive success. receive data length and php send data length the same.
I use StringToUint8Array , string conver to array, then use protobuf.js decode ,
My .proto file
But the LoginResponse.code < 128 is OK, if code == 129 the decode is change 253
The string type is the same, the string length == 129, error is
I think the question is Hight-order and Low-order of a uint32 ?
Then I try use js encode and decode protobuf is OK!!!
JS encode data the same to server, and all print to console
JS encode:
receive from server and StringToUint8Array
How can I do it, the protobuf.js has method from php encode protobuf string data conver to uint8array ? Thanks a lot !
The text was updated successfully, but these errors were encountered: