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.

GenerateId not working on 3x

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
BrianHVBcommented, Dec 23, 2020

@darrachequesne - Oops, yes, that does. Thank you.

1reaction
betooo0997commented, Nov 25, 2020

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!

Read more comments on GitHub >

github_iconTop 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 >

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