WebSockets

Note: The main intention behind this approach was to provide driverless network MIDI support for web applications. This was pretty much killed by the strict https requirement for websockets introduced in 2018. Websocket connections may still be used with non-browser clients like TouchDAW, but in general this functionality is no longer maintained.


WebSockets are part of the HTML5 specification and are supposed to offer realtime bi-directional communication channels for the web. TouchDAW / nmj can send MIDI over WebSockets from version 1.5.1 / 0.89 onwards and mnet provides a native implementation linkable to regular MIDI ports.

By itself this is just another way of sending MIDI over IP. Functionally it doesn't differ much from RTP and mnet will even use RTP encoded data when both sides of a connection support it. What mainly sets the two approaches apart is the transport layer: RTP runs on UDP while WebSockets use TCP. UDP does not guarantee packet delivery in any way. Especially on wireless networks data loss can and potentially will happen. TCP on the other hand promises to make 'best efforts' to get all data delivered, but this advantage may be bought with higher overall latency and jitter.


Using WebSockets to connect TouchDAW

Much like RTP channels, WebSocket channels primarily work over WIFI and can either be local servers or clients to remote servers. Equally they make themselves known to other peers via DNS. Apps that run on WebSocket channels will appear as remote devices in the control panel. In case of TouchDAW such channels will follow the same naming scheme used with RTP, namely: "tdaw (and_XX) WS 1 & 2". The XX will again be replaced with the last octet of the device's IP address.

If WebSocket servers are enabled in mnet, Android devices will pick them up and let users connect to them.

The upper patched channel in the following screenshot shows a remote channel. It represents TouchDAW's ("tdaw") first MIDI connection running on WebSockets ("WS 1") on an Android device with an IP address ending in .29 ("and_29").

The lower patched channel is the result of TouchDAW being connected to a WebSocket server run by the mnet driver on MIDI port 3. To enable websocket servers in mnet click the upper button on the MIDI port, check the WebSocket Server box and click OK.