WebSocket protocol rejects valid JSON strings
fixermark opened this issue ยท 3 comments
The WebSocket protocol is very white-space sensitive. This string works:
{"+":["v.altitude"]}
... this string does not:
{"+": ["v.altitude"]}
As such, this example from https://github.com/richardbunt/Telemachus/wiki/Web-Socket-API will not actually work:
{
"+": ["v.altitude", "v.name"],
"rate": 500
}
... attempting to send this input to Telemachus closes the socket connection with a '1006' status.
After some testing, I can confirm that removing all the space characters from the JSON query works and one doesn't get disconnected:
NOT WORKING
{
"+": ["v.altitude", "v.name"],
"rate": 500
}
WORKING
{"+":["v.altitude","v.name"],"rate": 500}
I have decided to strip all whitespace from the command string prior to running it through the regex. Obviously this doesn't work in general, but since all the API strings are whitespace free it makes for an easy fix.