【发布时间】:2017-04-02 00:54:11
【问题描述】:
我正在使用以下代码创建/订阅主题并处理消息。有时连接丢失,错误提示:
Whoops! The connection was lost...
我想知道是否有办法重新连接它。是否可以在错误回调中或在方法中定义整个代码并在错误回调中递归调用它?
$(document).ready(function () {
........
...............
try {
var socket = new SockJS("${createLink(uri: '/stomp')}");
var client = Stomp.over(socket);
client.connect({}, function () {
client.subscribe("/topic/${userInstance?.username}",
function (message) {
............
....................
});
});
} catch (error) {
console.log("ERROR: " + error.toString());
}
});
【问题讨论】:
-
天哪,我也需要答案:(