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