GenerateId not working on 3x
See original GitHub issueI want to:
- report a bug
- request a feature
Current behaviour
When setting io.engine.generateId
in v2.3.0, socket ids are set accordingly.
In 3x (tested on 3.0.0 and 3.0.3) they are not.
Steps to reproduce
In Node.js:
const express = require('express');
const app = express();
const server = require('http').Server(app);
const io = require('socket.io')(server);
const { v4: uuidv4 } = require('uuid');
io.engine.generateId = function (req)
{
return uuidv4();
}
Expected behaviour
As working in v2.3.0, the expected format of the socket ids should be, in this case, “xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”, being x alphanumerical. Instead I get the default socket id format.
Setup
- OS: Windows 10, running on Node.js
- socket.io version: 3.0.0 and 3.0.3
Other information (e.g. stacktraces, related issues, suggestions how to fix)
No errors are thrown, the format is simply not set.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
socket.io - GenerateId not working on 3x | bleepingcoder.com
When setting io.engine.generateId in v2.3.0, socket ids are set accordingly. In 3x (tested on 3.0.0 and 3.0.3) they are not.
Read more >io.engine.generateId not working (typescript) #245 - GitHub
Hello, I'm trying to change a socket.id by overriding the io.engine.generateId() function, but in typescript the engine property is private, ...
Read more >Apache Camel 3.x Upgrade Guide
This document is for helping you upgrade your Apache Camel application from Camel 3.x to 3.y. For example if you are upgrading Camel...
Read more >Socket.io: Overwritten generateId() gets executed, but the ...
For starters, return "custom:id:" + 1; is not unique. It generates the same value every time. Try at least making a unique value...
Read more >Randomness with JavaScript - DEV Community
Let's declare a hist object in the wrapper function and every time a random id is generated we can check if it's in...
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
@darrachequesne - Oops, yes, that does. Thank you.
Oh, okay! Thanks for the info.
I was reusing the
id
to transmit it to other clients for video calls using peer.js, but peer.js doesn’t like its format.But I just saw in the commit that you mentioned that I shouldn’t be doing this for security reasons, so I guess I can close this issue.
Thanks!