下がります。双方は、Autobahn.JSを使用してクロスバーサーバーに接続します。Autobahn.JSは、私は、データがクロスバー用WebSocketサーバー上でクライアント(Webサイト)とサーバ(Node.jsの)の間に送信されCrossbar.jsの実装を持っている接続
接続が正常に動作しますが、それは、クライアントとサーバーの接続解除の両方のようだとランダム瞬間に再接続します。これは約2分に1回発生します。私はまた、両方の側で同時に接続ドロップが発生していないことを見た。これは私が問題を両方の側で使用しているAutobahnの実装にあると思うようにしました(これはクライアントとサーバでほぼ同じです)。以下は
は私がNode.js.からクロスバーのサーバーに接続するために使用する方法であり、ブラウザのバージョンはほぼ同じです。私はサブスクリプションを変更し、const
とlet
変数をvar
に変更しました。
start(connectionConfig) {
const self = this;
self.host = connectionConfig.host;
self.realm = connectionConfig.realm;
self.channelPrefix = connectionConfig.channelPrefix;
try {
// Start an Autobahn websocket connection
self.connection = new autobahn.Connection({"url": self.host, "realm": self.realm});
self.connection.onopen = function(session) {
// Save session in class
self.session = session;
// Listen for incoming commands
session.subscribe(self.channelPrefix + 'smdc-server', self.onCommand.bind(self));
// Copy the class variable buffer to a local variable and set the
// class variable buffer to an empty array.
let localBuffer = self.socketBuffer;
self.socketBuffer = [];
// Send all messages from the local buffer that were 'send' using the class method (not displayed here on StackOverflow) while the connection was not yet established.
for (var i = 0; i < localBuffer.length; i++) {
session.publish(localBuffer[i].channel, [localBuffer[i].data]);
}
}
self.connection.onclose = function(reason, details) {
console.log("Autobahn closed!");
console.log("Reason: ");
console.log(reason);
console.log("Details: ");
console.log(details);
self.session = null;
}
self.connection.open();
} catch (err) {
console.log(err);
}
}
コードの部分にバグがあり、接続が切断されることはありません。
これは、どのようなコンソール出力です:
Autobahn closed!
Reason:
lost
Details:
{
reason: null,
message: null,
retry_delay: 1.4128745255660942,
retry_count: 1,
will_retry: true
}
Autobahn closed!
Reason:
lost
Details:
{
reason: null,
message: null,
retry_delay: 1.2303848117273903,
retry_count: 1,
will_retry: true
}
retry_count
変数は常に1
ですので、私は、接続はこれらの滴の間に復元されると思います。
これは何をクロスバーサーバの出力である:クロスバーのサーバーが切断および接続を表示することができますので
2017-08-23T10:46:34+0200 [Router 10622] session "1355162039012002" left realm "SMDC"
2017-08-23T10:46:35+0200 [Router 10622] session "2006451409833362" joined realm "SMDC"
2017-08-23T10:46:37+0200 [Router 10622] session "2006451409833362" left realm "SMDC"
2017-08-23T10:46:37+0200 [Router 10622] session "224071819838749" joined realm "SMDC"
、私はクロスバーに問題があるとは思いません。
私は、誰かが私を助け洞察力を持っている:)