Hi,
I am using latest version (so setup slightly different from the examples online), but from the client when I pass my response.data to decode I get an empty message back. I then was making a new Uint8Array(response.data) and this was working but I run into stack overflow issues on larger sets of data.
Checked issue #553 and the examples you directed them too but still no luck.
Server Code
let TestMessage = protobuf.load('./public/protos/message.proto')
.then((root) => {
TestMessage = root.lookup('testpackage.TestMessage');
})
router.get('/', function (req, res, next) {
const isFinal = Number(req.query.count) >= Math.pow(10, 4);
const count = isFinal ?
Number(req.query.count) :
Math.round(Number(req.query.count) * 1.5);
const data = crypto.randomBytes(count).toString('hex');
const msg = TestMessage.encode({
count,
data,
isFinal
}).finish();
res.send(msg);
});
Client Code
import axios from 'axios';
import * as protobuf from 'protobufjs';
const testTextArea = document.querySelector('textarea.test-area');
let TestMessage = protobuf.load('./protos/message.proto')
.then((root) => {
TestMessage = root.lookup('testpackage.TestMessage');
});
function init(count = 1) {
return axios.get('/data', {
params: {
count
},
responseType: 'arraybuffer'
})
.then((response) => {
const data = TestMessage.decode(response.data);
//TestMessage.decode(new Uint8Array(response.data)); <- works but have stack issues
testTextArea.innerHTML = data.data;
if (data.isFinal) { return; }
return init(data.count);
});
}
Hi,
I am using latest version (so setup slightly different from the examples online), but from the client when I pass my response.data to decode I get an empty message back. I then was making a new Uint8Array(response.data) and this was working but I run into stack overflow issues on larger sets of data.
Checked issue #553 and the examples you directed them too but still no luck.
Server Code
Client Code