0

I just want to deploy a simple node js application on heroku but it always throws me a request timeout error, I don't know why? Actually, first I tried with my main project but it didn't work then I try with some basic node js code, and after deploying I literally got shocked because it is also not working. Is this some problem related to the WebSockets library or I am doing wrong (Please let me know), I am tired of searching for a solution to this problem.

server.js

const Socket = require("websocket").server
const http = require("http")

const server = http.createServer((req, res) => {})

server.listen(process.env.PORT || 3000, () => {
    console.log("Listening on port 3000...")
})

const webSocket = new Socket({ httpServer: server })

webSocket.on('request', (req) => {
    const connection = req.accept()
    console.log("open")

    connection.on('message', (message) => {
        const data = JSON.parse(message.utf8Data)

        if(data.type == "message"){
            console.log(data.mess);
            connection.send(JSON.stringify(data))
        }
    })
})

Please help me to get out of this.

Amrit Gupta
  • 29
  • 1
  • 7

0 Answers0