在我的网络应用程序中,我使用Javascript连接到Phoenix频道。
this._channel = socket.channel("user:" + username, {password: password})
this._channel.join()
.receive("ok", this._handleLoginSuccess.bind(this))
.receive("error", this._handleLoginFailure.bind(this))
.after(10000, () => console.log("Networking issue. Still waiting..."))
服务器成功处理join
,并正确调用_handleLoginSuccess
回调。但是当启动JS调试器并查看this._channel
时,只要调用该回调,它就已经处于“错误”状态,并且我也无法向其发送任何消息。然而,我也看到joinedOnce
被设置为真,所以确实存在一些非常错误。
由于服务器端没有报告任何错误,我想知道发生了什么。有什么想法吗?
答案 0 :(得分:1)
我发现了问题:它与实时重新加载机制有关,它以某种方式导致websocket一直被终止并重新建立。通过评论下面的行来禁用实时重新加载后,我的常规频道再次正常工作。
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if(this.id == null) {
return false;
}
if (obj instanceof MyEntity && obj.getClass().equals(getClass())) {
return this.id.equals(((MyEntity) obj).id);
}
return false;
}
@Override
public int hashCode() {
int hash = 5;
hash = 43 * hash + Objects.hashCode(this.id);
return hash;
}