paho.mqtt.java icon indicating copy to clipboard operation
paho.mqtt.java copied to clipboard

IOException When Websocket Frame opcode == 0

Open yayuntian opened this issue 2 years ago • 1 comments

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

yayuntian avatar May 12 '23 02:05 yayuntian

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)

nuessgens avatar Aug 03 '24 01:08 nuessgens