Skip to content

Polling browser clients trip on large messages with TransportError #561

@stephank

Description

@stephank
  • OS: macOS 10.12.4
  • browser: Chrome 57.0.2987.133
  • engine.io version: 3.0.0 (client and server)

The following test results in the connection failing with:

engine.io-client:socket socket error {"type":"TransportError","description":{}} +49ms
engine.io-client:socket socket close with reason: "transport error" +1ms

server.js:

#!/usr/bin/env node

const fs = require('fs')
const http = require('http')
const engine = require('engine.io')

const TEST_LENGTH = 125300
const TEST_DATA = new Array(TEST_LENGTH + 1).join('a')

const server = http.createServer((req, res) => {
  if (req.url !== '/') {
    res.writeHead(501)
    res.end('Not Implemented')
  } else {
    res.writeHead(200, {
      'Content-Type': 'text/html; charset=utf-8'
    })
    res.end(fs.readFileSync('index.html'))
  }
})

engine.attach(server)
  .on('connection', (socket) => {
    socket.send(TEST_DATA)
  })

server.listen(3000)

index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test</title>
  </head>
  <body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/engine.io-client/3.0.0/engine.io.min.js"></script>
    <script>new eio.Socket('ws://localhost:3000/', { transports: ['polling'] })</script>
  </body>
</html>

Run server.js, navigate to localhost:3000, ensure debug=* is set in local storage to see the error happening.

I've tried reproducing this with a Node.js client, but that seems to work fine with messages much larger.

I've tried reproducing this in engine.io-parser, but that appears to encode and decode fine with messages much larger.

Setting { transports: ['websocket'] } in the client fixes the issue, and even works with messages much larger.

It appears this is a sweet spot; reducing the size of the test data with just 1 byte here makes it work again. However, in different scenarios, I've seen the number vary with < 10 bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions