LoginSignup
0
0

More than 3 years have passed since last update.

Tomcat + WebSocket で 1002 エラー

Posted at

結論

WebSocket で 1002エラーが発生するとサーバー側でエラーが発生している可能性が高い。

経緯

JavaScript に限らないが、WebSocket プログラミングでサーバーから 1002 のエラーコードが返ることがある。


ws.onclose = function(event) {
    if (event.wasClean) {
        alert("[close] Connection closed cleanly");
    } else {
    console.log("[close] Connection died " + event.code + "," + event.reason);
    }
};

[close] Connection died 1002,An unrecoverable IOException occurred so the connection was closed

しかしサーバー側(Tomcat 8.5) のコンソールを見ても何も表示されていない。ここでハマった。

(なぜだろう... と半日経過)

サーバー側のコードをよく見ると、NullPointerException になるケースがあることがわかり、修正したところ意図通りに動作するようになった。
NullPointerException が出ているのであればサーバーのコンソールでも出力されてほしいところではある。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0