javascript - Amqp无法连接时如何接收异常?
问题描述
const amqp = require('amqp-connection-manager')
const {CONNECTION_URL} = require('./config/env')
class AmqpConnectionService {
async openConnection() {
this.connection = await amqp.connect([CONNECTION_URL])
this.channelWrapper = await this.connection.createChannel({setup(channel) {}})
await this.channelWrapper.waitForConnect()
}
使用此代码,当CONNECTION_URL
URL 错误时,代码会卡在waitForConnect()
.
解决方案
推荐阅读
- python-3.x - 用python数学找到P的x(abs(|X|)> X)
- swift - 为什么我的 UIAlertController 在被调用时没有出现?
- python - 90° 矩阵旋转 Python
- assembly - 将两个负数相乘时,imul 的 MASM32 问题
- javascript - SuiteScript 在客户端脚本中创建文件
- r - 按列值过滤数据框的行
- flutter - CupertinoPicker 无法从选定值返回文本
- vim - 为什么我可以在单行中声明 if 而不是 Vimscript 中的函数?
- r - 创建一个逻辑以在具有两个元素的列表中捕获两种类型的不等式
- linux - 如何通过按取消按钮关闭 zenity 窗口?