Production-ready WebSocket and WSS for VBA with native TLS, auto reconnect, proxy support, MQTT, permessage-deflate, and zero external dependencies
[!NOTE] Supported Applications
![]()
![]()
![]()
![]()
and
[!IMPORTANT] Platform
Currently available only on Windows, as it relies on Windows-specific APIs to function.
Wasabi is a VBA module designed to make WebSocket communication simple, predictable, and practical, bringing an experience similar to socket.io in Node.js entirely within the Office ecosystem. It is a single, self-contained .bas file that compiles seamlessly on 32-bit and 64-bit Office hosts, from Windows XP to Windows 11.
Beyond basic WebSocket messaging, Wasabi bundles an MQTT 3.1.1 client, NTLM/Kerberos proxy authentication, RTT latency measurement, fine-grained TLS certificate control, and permessage-deflate compression (RFC 7692), all without mandatory external dependencies.
WSAAsyncSelect event-driven socket notificationsWebSocketStartListening helper for one-line polling loopsVBA is excellent for automation and integration with Excel, PowerPoint, Word, and other Office applications, but it hits a wall when real-time communication is required. In practice, anyone trying to build a project that depends on live messaging usually runs into three problems:
Aqui está a seção dedicada exclusivamente à explicação técnica da escolha do formato de módulo padrão (.bas), integrada ao seu Markdown e otimizada para ser informativa e profissional:
A common architectural question is why Wasabi is implemented as a standard procedural module rather than an Object-Oriented class. This design is a deliberate strategic choice to maximize performance, stability, and compatibility within the specific constraints of the VBA environment.
In VBA, every Class is technically a COM (Component Object Model) Object. Instantiating, invoking methods via IDispatch, and managing reference counting adds significant overhead. By using a standard .bas module, Wasabi communicates directly with the CPU and memory, eliminating the COM layer and providing the high-speed execution required for real-time networking.
Wasabi manages up to 64 concurrent connections using a statically allocated pool of User-Defined Types (UDTs).
Working with low-level networking requires heavy use of memory pointers (StrPtr, VarPtr) and direct memory manipulation (RtlMoveMemory).
Using Wasabi does not require the developer to manage object lifecycles or worry about variables falling out of scope and terminating connections unexpectedly.
Wasabi is engineered to maximize developer productivity by leveraging the global scope of standard modules. By using Public Enums and Types, we provide a superior IntelliSense experience compared to Class-based libraries:
STATE_OPEN, STATE_CLOSED) and error codes anywhere in your project without instantiating objects.WasabiStats for high-performance data handling and telemetry.WebSocketGetLastError return specific Enum values, allowing for clean Select Case blocks and self-documenting code.[!TIP] This architecture transforms Wasabi from a simple script into a high-performance networking engine, bringing C-level memory management and stability to the VBA ecosystem.
Working with networking in VBA often becomes a project of its own. Wasabi addresses typical pain points directly:
Winsock and Windows API calls
Security & Cryptography
CryptGenRandom for RFC-compliant frame masking instead of VBA’s predictable Rnd.Corporate Environments
winhttp.dll.HTTP is not WebSocket
Maintenance and readability
Modern Asynchronous Networking
Reliability
Built-in IoT and Diagnostics
MqttConnect, MqttPublish, MqttSubscribe).Download the latest version of Wasabi and import it into your VBA project via File → Import File in the VBA editor.
No references need to be enabled in Tools → References.
Dim h As Long
If WebSocketConnect("wss://echo.websocket.org", h) Then
WebSocketSend "Hello, Wasabi!", h
Dim msg As String
msg = WebSocketReceive(h)
If msg <> "" Then
Debug.Print "Received: " & msg
End If
WebSocketDisconnect h
End If
Dim h As Long
WebSocketSetCertValidation True, h
WebSocketSetRevocationCheck True, h
If WebSocketConnect("wss://example.com/ws", h) Then
WebSocketSend "Secure hello", h
WebSocketDisconnect h
End If
Dim h As Long
' Connect with MQTT subprotocol declaration
WebSocketConnect "wss://broker.hivemq.com:8443/mqtt", h, , , "mqtt"
MqttConnect "WasabiClient_123", , , 60, h
' Publishes and tracks delivery via internal In-Flight queue
MqttPublish "sensors/data", "Value: 42", 1, False, h
Dim h As Long
' Set third parameter to True to enable Deflate
If WebSocketConnect("wss://example.com/ws", h, True) Then
Debug.Print "Compression active: " & WebSocketGetDeflateEnabled(h)
WebSocketSend "Compressed message payload", h
WebSocketDisconnect h
End If
[!WARNING] Compression requires
zlib1.dllto be present alongside your project file. Without it, compression is silently disabled and the connection proceeds normally. See DEFLATE.md for detailed setup instructions.
Dim h As Long
' Hardcoded proxy or use WebSocketAutoDiscoverProxy()
WebSocketSetProxy "proxy.company.com", 8080, "user", "pass", 0, h
WebSocketSetProxyNtlm True, h
If WebSocketConnect("wss://example.com/ws", h) Then
WebSocketSend "Behind the firewall", h
WebSocketDisconnect h
End If
Dim h As Long
' Set max attempts to 5, base delay to 1000ms
WebSocketSetAutoReconnect True, 5, 1000, h
WebSocketSetPingInterval 30000, h ' Send ping every 30s
If WebSocketConnect("wss://example.com/ws", h) Then
Do While WebSocketIsConnected(h)
Dim msg As String
msg = WebSocketReceive(h)
If msg <> "" Then Debug.Print "Received: " & msg
DoEvents
Loop
End If
For the complete reference with examples, parameters, return values, and usage notes, see the API Reference.
All cryptographic and encoding primitives are delegated to native Windows
APIs (advapi32.dll / crypt32.dll). This yields throughput close to the
hardware limit, even inside the VBA runtime.

[!NOTE] SHA‑1 now runs at 400 MB/s (down from 1.8 s per 128 KB in pure VBA). Base64 operations stay around 41 MB/s, UTF‑8 conversion exceeds 1 GB/s, and WebSocket frame construction tops 25 MB/s.
The test harness and raw data are in
benchmark/.
Wasabi was designed to run without any external dependencies, using exclusively
native Windows DLLs that ship with every version of Windows. No references need
to be enabled in Tools → References, no COM components need to be registered,
and no third-party installers are required. Dropping the .bas file into a VBA
project is all it takes.
| Version | Support |
|---|---|
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ |
Wasabi relies on ws2_32.dll, secur32.dll, kernel32.dll, advapi32.dll, and crypt32.dll. These libraries are present in every version of Windows since XP, which is why Wasabi runs on machines over 20 years old without modifications.
This is a deliberate architectural choice. Many competing modules depend on the WinHttpWebSocket* family of functions (WinHttpWebSocketSend, WinHttpWebSocketReceive, WinHttpWebSocketCompleteUpgrade) introduced only in Windows 8. As a result, those modules silently fail on Windows 7 machines, which remain common in corporate and industrial environments. Wasabi has no such limitation.
| Environment | Support |
|---|---|
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ | |
| ✅ |
The transition from 32-bit to 64-bit Office broke many VBA modules that used native API declarations. Wasabi handles this transparently through conditional compilation.
Every API declaration uses #If VBA7 to switch between Long (32-bit) and
LongPtr/PtrSafe (64-bit). The same .bas file works correctly on Office
2007 32-bit and Office 365 64-bit on Windows 11.
32-bit and 64-bit compatibility is guaranteed through conditional compilation (
#If VBA7) across all API declarations.
| Library | Role in Wasabi | Optional |
|---|---|---|
ws2_32.dll |
TCP socket creation, DNS, send/recv | No |
secur32.dll |
TLS 1.2/1.3 via Schannel SSPI | No |
kernel32.dll |
Memory operations, UTF-8, tick count | No |
advapi32.dll |
Cryptographic random numbers (CryptGenRandom) |
No |
crypt32.dll |
Certificate store, chain validation | No |
zlib1.dll |
Compression for permessage-deflate |
Yes |
What does “zero external dependencies” mean in practice?
Wasabi requires nothing beyond Windows and the standard VBA runtime. There is no installer, no COM registration, no ActiveX control, no third-party DLL, no Python runtime, no .NET package, and no regsvr32.
The only optional component is zlib1.dll, needed strictly if you enable permessage-deflate. The module detects its presence automatically and works perfectly without it. This is highly beneficial in corporate environments where IT policies prevent software installation. You can distribute a workbook containing Wasabi without asking the user to install anything first.
Wasabi supports the WebSocket permessage-deflate extension (RFC 7692), which
compresses message payloads to reduce bandwidth usage.
zlib1.dll (see Native DLLs and DEFLATE.md)' Connect with compression enabled
If WebSocketConnect("wss://example.com/ws", h, True, True) Then
Debug.Print "Compression active:", WebSocketGetDeflateEnabled(h)
End If
[!NOTE]
permessage-deflatereduces bandwidth, not latency. It’s most beneficial for large payloads or connections with limited bandwidth. For small messages, the CPU overhead may slightly outweigh the bandwidth savings.
VBA is single-threaded. One execution thread is shared between your code and the Office interface, so there is no native background socket listening.
Wasabi uses a polling model: incoming messages accumulate in internal buffers
and are delivered when you call WebSocketReceive.
Each WebSocketReceive call:
FIONREAD)Between calls, the socket stays open and the kernel buffers incoming data. No messages are lost.
The research/ directory contains detailed design notes, investigation logs, and reference materials for every major subsystem in Wasabi. It is intended for maintainers and advanced users who want to understand why certain decisions were made, not just what the code does. Topics include TLS verification, pointer fixes, permessage-deflate negotiations, Happy Eyeballs, MTU discovery, MQTT state logic, zero-copy buffer management, fragmentation, and VBA6 compatibility.
Wasabi was built on years of community efforts to bring real-time networking to the Office ecosystem.
These projects shaped every architectural decision in Wasabi: the non-blocking I/O model, manual Schannel handling, ring buffers, and auto-reconnect flows.
Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md.
Do not report vulnerabilities through public issues. See SECURITY.md and use GitHub Private Vulnerability Reporting.
MIT, free for personal and commercial use. See LICENSE.