-
Notifications
You must be signed in to change notification settings - Fork 612
Closed
Description
Hey
I'm trying to use uWebSockets with Socket.io,
but I keep getting this error, and I noticed that it only happens when I use Safari:
node:buffer:254
TypedArrayPrototypeSet(target, source, targetStart);
^
TypeError: Cannot perform %TypedArray%.prototype.set on a detached ArrayBuffer
at Buffer.set (<anonymous>)
at _copyActual (node:buffer:254:3)
at Function.concat (node:buffer:562:12)
at onEnd (/Users/.../node_modules/engine.io/build/transports-uws/polling.js:126:32)
at /Users/tahayk/.../node_modules/engine.io/build/transports-uws/polling.js:143:17
Node.js v17.0.1
Here is the example I used:
server.js:
const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");
const app = new App();
const io = new Server({ cors: {
origin: "*",
methods: ["GET", "POST", "PUT"]
}});
io.attachApp(app);
io.on("connection", (socket) => {
// ...
});
app.listen(9000, (token) => {
if (!token) {
console.warn("port already in use");
}
});demo.html
<!doctype html>
<html>
<head>
<title>Socket.IO uWS</title>
</head>
<script src="node_modules/socket.io/client-dist/socket.io.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
$(function () {
var socket = io(
'ws://127.0.0.1:9000',
{
// transports: ["websocket"] // ----> it works if you add this
});
socket.onAny((eventName, ...args) => {
console.log("received event: " + eventName);
});
});
</script>
<body>
</body>
</html>Any idea about this issue ?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels