Skip to content

Websocket stuck after receiving around ~16 kb of data from client #80

@zmeyc

Description

@zmeyc

🐛 Bug Report

After client sends ~100 messages of ~160 bytes each to websocket, connection.socket.on('message') is no longer being triggered.

It seems to be size-dependent, I can send thousands of very short (a few bytes) messages, but only around 100 lines of 160 bytes.

To Reproduce

In new dir:

yarn init
yarn add fastify fastify-websocket

Create server.js:

'use strict'

const fastify = require('fastify')()

fastify.register(require('fastify-websocket'))

fastify.get('/', { websocket: true }, (connection, req) => {
  connection.socket.on('message', message => {
    // message === 'hi from client'
    connection.socket.send('hi from server')
  })
})

fastify.listen(5000, err => {
  if (err) {
    fastify.log.error(err)
    process.exit(1)
  }

Run node server.js

In another window, run:

wscat --show-ping-pong -c "ws://localhost:5000"

Create a file with ~150 lines of 160 bytes each. Copy-paste contents into wscat.

The server will stop responding.

Expected behavior

Should keep returning responses.

Your Environment

  • node version: 12
  • fastify version: >=2.0.0
  • os: Mac, Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions