question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When Server Socket emit Buffer to Client, browser Client receive Empty ArrayBuffer

See original GitHub issue

server.js

var express = require(‘express’); var app = express(); var http = require(‘http’); var server = http.createServer(app); var io = require(‘socket.io’)(server);

app.get(‘/’, function(req, res) { res.sendfile(‘test.html’); });

io.on(‘connection’, function(socket) { console.log(socket);

var buf = new Buffer(1);
buf.writeUInt8(1, 0, 1);

socket.emit("data", buf);

}); server.listen(3000);

test.html

var socket = io.connect(“http://localhost:3000”); socket.on(‘data’, function(data) { console.log(data); });

In the test.html receive data is empty ArrayBuffer, use nodejs client is ok

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
darrachequesnecommented, Jan 6, 2017

@MertOtrk oh! that might be because you use that browser

image

How in the world are we supposed to fix without a proper way to reproduce? (which browser, which socket.io version?..)

Love ❤️

0reactions
ghostcommented, Jan 6, 2017

Thank you, its worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with sending buffer over Socket.IO - node.js
Everything looks good on the client side except that data.buffer is an ArrayBuffer (not a Buffer) and the length is undefined (the ArrayBuffer...
Read more >
Emitting events | Socket.IO
Another use case is to discard events when the client is not connected (by default, the events are buffered until reconnection). Example: // ......
Read more >
engine.io-client
With browsers that don't support ArrayBuffer, an object { base64: true, data: dataAsBase64String } is emitted on the message event. API. Socket. The...
Read more >
node_modules/engine.io-client - Git ECE IASTATE
Features · Receives as ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node · When XHR2 or WebSockets are used,...
Read more >
Node.js v19.3.0 Documentation
Static method: Buffer.alloc(size[, fill[, encoding]]); Static method: Buffer. ... Server-side example; Client-side example; Class: Http2Session.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found