It sounds like perhaps postData is a Uint8Array but req.write() expects to be passed either a string or a Buffer <https://nodejs.org/api/buffer.html#buffer_class_buffer>. Maybe the right solution is to convert postData to a Buffer before calling req.write().
On Tue, Nov 15, 2016 at 8:49 PM, Jorg Janke <[email protected]> wrote: > I am trying to send/receive protoc with Node and in a Javascript client. > > With the Node code below, I get: TypeError: First argument must be a > string or Buffer > What am I missing? > > The actual server is Java based. > > Thanks! > Jorg > > : > > var postData = protoRequest.serializeBinary(); // Uint8Array > > var options = { > protocol: 'https:', > hostname: 'xxx', > port: 443, > path: '/xxx', > method: 'POST', > headers: { > 'Content-Type': 'application/application/x-google-protobuf', > 'Content-Length': Buffer.byteLength(postData) > } > }; > > var req = https.request(options, function(res) { > res.on('data', function(chunk) { > var responseMessage = ProtoResponse.deserializeBinary(chunk); > console.log("Response", responseMessage); > > }); > }); > req.write(postData); > req.end(); > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
