-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mqtt模拟器):新增断开重试参数 #7
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重试时,似乎也不能触发脚本中的beforeConnect监听,无法自定义用户名密码规则。
if (counter > options.getReconnectAttempts() && !isAlive()) { | ||
dispose(); | ||
} else { | ||
Address localAddress = AddressManager.global().takeAddress(options.getLocalAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不应该获取新的地址吧?
dispose(); | ||
} else { | ||
Address localAddress = AddressManager.global().takeAddress(options.getLocalAddress()); | ||
Disposables.composite() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disposables.composite().add()没啥意义,应该将Disposable添加到当前client中,在手动断开时,能取消重试任务。
.flatMap(i -> Mono.<MqttClient>create(sink -> this.connect1(client, options, localAddress, sink))) | ||
.subscribe(mqttClient -> { | ||
log.info("客户端尝试重连:{},次数:{}", mqttClient.getId(), counter); | ||
counter++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
连接失败时似乎并不会触发这里。
|
||
disposables = Mono.delay(Duration.ofMillis(options.getReconnectInterval())) | ||
.doOnNext(i -> fallback.run()) | ||
.flatMap(i -> Mono.<MqttClient>create(sink -> this.connect1(client, options, this.address, sink, counter, fallback))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里重试不应该创建新的MqttClient,而是替换 当前对象中的 io.vertx.mqtt.MqttClient
,否则可能无法发送消息。
No description provided.