mqtt-elements icon indicating copy to clipboard operation
mqtt-elements copied to clipboard

processing large messages - Websocket connection to 'ws://localhost:8080/' failed: Invalid frame header

Open cordovapolymer opened this issue 8 years ago • 7 comments

When receiving large messages with mqtt-elements Websocket connection to 'ws://localhost:8080/' failed: Invalid frame header error occurs.

As per specification large messages have to be encoded differently. I have found javascript implementation of this: http://stackoverflow.com/a/10402443

cordovapolymer avatar Sep 06 '16 08:09 cordovapolymer

@cordovapolymer could you post an example to reproduce this and specify what a large message is. This is probably a bug at MQTT.js itself.

sandro-k avatar Sep 06 '16 09:09 sandro-k

Full error is WebSocket connection to 'ws://example.com:8000/ws' failed: Invalid frame header WebSocket connection to 'ws://example.com:8000/ws' failed: One or more reserved bits are on: reserved1 = 0, reserved2 = 1, reserved3 = 1

One or more reserved bits are on: reserved1 = 0, reserved2 = 1, reserved3 = 1 it happens in mqtt-elements.js at line 7415 in instance = new WebSocket(uri, protocols); Approximate message size is ~300KB. I couldn't test it with your demo because it isn't showing received messages.

cordovapolymer avatar Sep 06 '16 16:09 cordovapolymer

I am not able to reproduce this.. I am publishing a large message to the broker and correctly receive it at the client. Could you post the code that you are using to connect, subscribe and publish the message.

sandro-k avatar Sep 07 '16 09:09 sandro-k

I am not able to reproduce this.. I am publishing a large message to the broker and correctly receive it at the client. Could you post the code that you are using to connect, subscribe and publish the message.

It seems that this error comes from mosquitto broker, I tried it with MQTT.js 2.0.1 and got the same error, and when switched to aedes it has disappeared.

cordovapolymer avatar Oct 24 '16 01:10 cordovapolymer

There might be an issue on the difference between websocket-stream and a basic tls/net stream.

I'll try to see if I can assemble a PR.

mcollina avatar Oct 24 '16 16:10 mcollina

@mcollina wait until the end of the week. I will invest some time in mqtt-elements and update to the current mqtt.js version and will make some code cleanup.

sandro-k avatar Oct 24 '16 16:10 sandro-k

Same issue.

damouse avatar Aug 02 '18 20:08 damouse