Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket Freeze Issue During High Data Volume in Node.js Application #4361

Closed
Gabriel-id opened this issue Mar 20, 2024 · 4 comments
Closed

Socket Freeze Issue During High Data Volume in Node.js Application #4361

Gabriel-id opened this issue Mar 20, 2024 · 4 comments

Comments

@Gabriel-id
Copy link

Details

I'm having a problem with a Node.js application. This application is a client that reads data from a TCP connection using net.socket. When there's a sudden surge in data volume, the socket appears to freeze, preventing further data arrival. After a period of being stuck, the socket unlocks, and the previously withheld data starts arriving, as if it had been temporarily held back and then released.

Node.js version

18.7.1

Example code

const connect = require('node:net').connect
const PassThrough = require('node:stream').PassThrough

const TELNET_HOST = process.env.TELNET_HOST
const TELNET_PORT = process.env.TELNET_PORT

const broadcaster = new PassThrough()
const socket = connect(
  {
    host: TELNET_HOST,
    port: TELNET_PORT,
    onread: {
      buffer: Buffer.alloc(32 * 1024),
      callback: (nread, buffer) => socket.emit('data', buffer.subarray(0, nread)),
    },
  },
  () => console.info('Connected')
)

socket.on('data', (data) => broadcaster.write(data))

Operating system

Linux

Scope

code and runtime

Module and version

Not applicable.

@gireeshpunathil
Copy link
Member

@Gabriel-id -

  • when you say sudden surge in data volume, what is it like? MBs? GBs? TBs?
  • why are you re-emitting? can't you do broadcaster.write in the callback itself?

@Gabriel-id
Copy link
Author

Gabriel-id commented Mar 21, 2024

@Gabriel-id -

  • when you say sudden surge in data volume, what is it like? MBs? GBs? TBs?
  • why are you re-emitting? can't you do broadcaster.write in the callback itself?
  • Some MBs
  • Yes, it would be possible. It was just one of the tests I was conducting.

@gireeshpunathil
Copy link
Member

Yes, it would be possible. It was just one of the tests I was conducting.

ok - try that. i.e, omit the unread callback and just do things in socket.on(data) callback and see if it removes the freeze?

@Trott
Copy link
Member

Trott commented Apr 5, 2024

Closing as it's been 2 weeks without a reply to the suggestion in #4361 (comment).

@Trott Trott closed this as completed Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants