mqttjs / mqtt-elements

Polymer elements for MQTT
http://mqttjs.github.io/mqtt-elements/
MIT License
27 stars 6 forks source link

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

Open cordovapolymer opened 8 years ago

cordovapolymer commented 8 years ago

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

sandro-k commented 8 years ago

@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.

cordovapolymer commented 8 years ago

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.

sandro-k commented 8 years ago

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.

cordovapolymer commented 7 years ago

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.

mcollina commented 7 years ago

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.

sandro-k commented 7 years ago

@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.

damouse commented 6 years ago

Same issue.