[Ovmsdev] OVMS Server v3 WebSockets
Mark Webb-Johnson
mark at webb-johnson.net
Fri Jul 18 15:24:12 HKT 2025
I’ve made, committed, and pushed, a couple of (hard to find but easy to fix) changes to OVMS Server v3.
Proper handling of non-textual, non-binary, websocket messages. This issue caused garbage to be received when some websocket clients disconnected nicely (with connection close messages badly handled). The fix is to only treat text and binary messages as OVMS v2 protocol, and to ignore the other purely-control messages.
The websocket library we use may UTF-8 encode incoming messages leading to garbage messages being sent to connected cars/apps and disconnections. The fix made is simply to treat the messages as streams of bytes (not UTF-8 encoded).
With these changes made, all my tests of websocket clients (and apps) are complete and pass. Hopefully this should be stable to use in production now. It is certainly very easy to use.
Car:
$ websocat -E wss://<server>:6870/apiv2
MP-C 1 <user> <password> <vehicleid>
MP-S 1 <user> <vehicleid-list>
Z0
Z1
C7,stat
c7,1,all ok
Z0
App:
$ websocat -E wss://<server>:6870/apiv2
MP-A 1 <user> <password> <vehicleid>
MP-S 1 <user> <vehicleid-list>
Z1
F1.5.0,VIN123456789012345,5,1,TRDM,
S80,K,220,13,charging,standard,282,253,13,18,0,0,5,1,0,0,0,1
D124,8,4,10,20,5,0,9930,50,0,0,0,1,1,12.0,0
L22.337297,114.187969,90,0,1,1
W29,2,40,6,29,2,40,6,1
T15
C7,stat
c7,1,all ok
This new code is running at api.openvehicles.com <http://api.openvehicles.com/> already, and I recommend anyone running their own server to upgrade if they need websocket (or new unified app) support.
Regards, Mark.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20250718/43e38bb1/attachment.htm>
More information about the OvmsDev
mailing list