When Server Socket emit Buffer to Client, browser Client receive Empty ArrayBuffer
See original GitHub issueserver.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:
- Created 9 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MertOtrk oh! that might be because you use that browser
How in the world are we supposed to fix without a proper way to reproduce? (which browser, which socket.io version?..)
Love ❤️
Thank you, its worked.