小编qBe*_*ays的帖子

Heroku 错误:Web 进程无法在启动后 60 秒内绑定到 $PORT(使用 axios)

这是完整的错误代码:错误 R10(启动超时)-> Web 进程未能在启动后 60 秒内绑定到 $PORT

很多答案都说这与设置端口有关,因为heroku是动态设置的,但是如果我使用axios而不是server.listen,并且需要mcsrv api的特定端口,我将如何解决这个问题?

我已经尝试将其设置为 process.env.PORT 但无济于事(以及使用 || 语句将其设置为默认端口)

 // Function for getting player counts
require('dotenv').config()

const axios = require('axios')

function pingForPlayers() {

    // Ping API for server data.

    axios.get(`https://api.mcsrvstat.us/2/play.lightningshot.net`)
    .then(response => {

        // If it gets a valid response

        if(response.data && response.data.players) {

            let playerCount = response.data.players.online || 0 // Default to zero

            info = `${playerCount}`

            client.channels.get('605543627208392875').setName("Players Online: " + info)

            // Could add console.log for more info, not necessary waste of cache data …
Run Code Online (Sandbox Code Playgroud)

heroku node.js discord discord.js

4
推荐指数
1
解决办法
6821
查看次数

标签 统计

discord ×1

discord.js ×1

heroku ×1

node.js ×1