eclipse-paho / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.14k stars 886 forks source link

IOException When Websocket Frame opcode == 0 #1000

Open yayuntian opened 1 year ago

yayuntian commented 1 year ago

Bug exists Release Version 1.2.5 ( Master Branch)

public WebSocketFrame(InputStream input) throws IOException { ..... throw new IOException("Invalid Frame: Opcode: " + this.opcode);

https://www.rfc-editor.org/rfc/rfc6455#section-5.2 SDK should support opcode 0

nuessgens commented 2 months ago

It seems that the same happens for opcode 0x9 (PING). Or - to be preceise - the exception is thrown for anything other than opcode 0x2 (BINARY) and opcode 0x8 (CLOSE).

Unfortunately mosquitto seems to send PING WS-Frames form time-to time (exactly after 5 minutes; no matter how much activity was on the ws-connection before) This than triggerd all the side-effects of the last-will etc.

Took me several hours to find out that this is a bug in paho mqtt websocket implementation. Sadly figuring this out took longer than writing an own NetworkModuleFactory for websockets based on the jdk11 java.net websocket-client.

If websocket is ment to be supported the paho java mqtt client has at least cover the basic websocket-spec (like the opcodes and also respond to the PING frame with a PONG 0xA echoing the content)