Volatile not working from server to client with binary data
See original GitHub issueDescribe the bug Sending a volatile event from the client (Chrome) to Node with binary data works fine. Sending a volatile event from Node to the client with binary data does not work. Sending binary data without volatile works, sending non binary data with volatile works.
To Reproduce
Socket.IO server version: 4.1.1
Server
import { createServer } from "http";
import { Server, Socket } from "socket.io";
const httpServer = createServer({});
const io = new Server(httpServer, {
cors: {
origin: "http://localhost:8080",
methods: ["GET", "POST"],
},
});
io.on("connection", (socket) => {
socket.on("some event", (data) => {
console.log(data);
});
setTimeout(() => {
socket.volatile.emit("some event", "hello");
// socket.volatile.emit("some event", new ArrayBuffer(10));
}, 1000);
});
httpServer.listen(3000);
Socket.IO client version: 4.1.1
Client
import { io } from "socket.io-client";
this.socket = io("http://localhost:3000");
this.socket.on("some event", (data) => {
console.log(data);
});
setTimeout(() => {
this.socket.volatile.emit("some event", new ArrayBuffer(10));
}, 1000);
works fine, changing the server code:
setTimeout(() => {
// socket.volatile.emit("some event", "hello");
socket.volatile.emit("some event", new ArrayBuffer(10));
}, 1000);
and the client receives nothing
Expected behavior The client receives the binary data.
Platform:
- OS: Linux 5.10
- Node 15.14.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Emitting events | Socket.IO
Volatile events are events that will not be sent if the underlying connection is not ready (a bit like UDP, in terms of...
Read more >Java Concurrency - Volatile, Final and Atomics @ https ...
CAUTION: Volatile variables do not provide any atomicity. For example, the method is not guaranteed to flip the value of the field. There...
Read more >Netty binary data not flush out until 0x0a - Stack Overflow
My netty server application needs to reply to the client with binary data, but it seems flush out only when 0x0a is reached....
Read more >Socket.IO 3 - Best HTTP/2 Documentation
IO server implementation binds to the /socket.io/ path, and the client going to append it to the uri if the ... Binary data...
Read more >Understanding "volatile" qualifier in C | Set 1 (Introduction)
We think that the main reason for this is due to not having real-world use-case of a 'volatile' variable in typical C programs...
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
I could indeed reproduce the issue. We will publish a fix as soon as possible.
@brako zut, you are right. This should be finally fixed by https://github.com/socketio/socket.io-adapter/commit/88eee5948aba94f999405239025f29c754a002e2, included in
socket.io-adapter@2.3.3
(which should be included by latestsocket.io
by transitivity).I added a test case here, to prevent any regression in the future.
Please reopen if needed.