0
我正在使用以下代碼來創建/訂閱主題並處理消息。有時連接丟失,錯誤說:斷開連接時重新連接跺腳
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());
}
});
哦,上帝,我需要的答案太:( – akiong