Socket.io and Heroku - App crashed with status 503 - problem with "/socket.io/?EIO=3&transport=polling" random

Viewed 534


I'm working on an app hosted by Heroku that uses Socket.io and Express. It's like a chat app with different rooms.

Sometimes (I don't understand when) there's a bug that makes app crash:

at=error code=H10 desc="App crashed" method=GET path="/socket.io/?EIO=3&transport=polling&t=N4rsTCG" request_id=d10f368f-7617-4d15-af4a-6caefee70e44 fwd="47.30.198.19" dyno= connect= service= status=503 bytes= protocol=https

I don't think the problem is Heroku but Socket.io
As I said, the bug is not always reproducible but it occurs randomly. I cannot reproduce locally.

This is part of the server.js:

const express = require("express");
const app = express();
const http = require("http").createServer(app);
const io = require("socket.io")(http);
const bodyParser = require("body-parser");

const PORT = process.env.PORT || 3000;
...

This is part of the client.js:

const socket = io();
...
socket.emit("join", room);
...

This is the package.json:

{
  "name": "",
  "version": "0.0.1",
  "description": "",
  "dependencies": {
    "body-parser": "^1.19.0",
    "express": "^4.15.2",
    "socket.io": "^2.3.0"
  },
  "scripts": {
    "start": "node server.js"
  }
}

I have read that it could be a 404 when socket.io try to get EIO=3&transport=polling, but why does it happen randomly? Can it be because of Heroku and a problem related to dynos?

Thank you!

0 Answers
Related