2 回答
TA贡献1868条经验 获得超4个赞
错误R10(引导超时)-> Web进程在启动后90秒钟内未能绑定到$ PORT
该错误告诉我们,您需要侦听heroku将提供给我们的端口。所以做吧
public class Bot extends TelegramLongPollingBot {
private static final String TOKEN = System.getenv("TOKEN");
private static final String BOT_USERNAME = System.getenv("BOT_USERNAME");
private static final String PORT = System.getenv("PORT");
public void onUpdateReceived(Update update) {
}
public String getBotUsername() {
return BOT_USERNAME;
}
public String getBotToken() {
return TOKEN;
}
public static void main(String[] args) {
ApiContextInitializer.init();
TelegramBotsApi api = new TelegramBotsApi();
try {
api.registerBot(new Bot());
} catch (TelegramApiRequestException e) {
e.printStackTrace();
}
try (ServerSocket serverSocket = new ServerSocket(Integer.valueOf(PORT))) {
while (true) {
Socket clientSocket = serverSocket.accept();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
TA贡献1846条经验 获得超7个赞
在浪费大量时间尝试修复此R10错误后对我有很大帮助。我可以追加将Procfile放置在根目录中,如下所示:
web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/<custom-bot>.jar
添加回答
举报