wasabi

Error Reference

This document describes every error code in the WasabiError enumeration, including what triggers each error, what the associated system codes mean, and how to diagnose and resolve common failures.

Reading Wasabi Errors

Wasabi exposes three levels of error information per connection.

Dim errType As WasabiError
Dim sysCode As Long
Dim details As String

errType = WebSocketGetLastError(handle)
sysCode = WebSocketGetLastErrorCode(handle)
details = WebSocketGetTechnicalDetails(handle)

Debug.Print "Error:", errType
Debug.Print "System code:", sysCode
Debug.Print "Details:", details

errType is the high-level Wasabi error category. It tells you what failed.

sysCode is the raw error code from the underlying system call. For Winsock errors, this is a WSA error code. For TLS errors, this is an SSPI/HRESULT status code. For successful operations, this is zero.

details is a human-readable string describing the specific failure, including the function name and the numeric code. This is the most useful field for debugging.

[!TIP] Always log all three values when diagnosing connection issues. The WebSocketGetErrorDescription function combines them into a single diagnostic string.

Error Pattern

A typical error handling pattern looks like this.

Sub ConnectSafely()
    Dim h As Long

    If Not WebSocketConnect("wss://echo.websocket.org", h) Then
        Select Case WebSocketGetLastError(h)
            Case ERR_DNS_RESOLVE_FAILED
                Debug.Print "Cannot resolve hostname"
            Case ERR_CONNECT_FAILED
                Debug.Print "Server unreachable"
            Case ERR_TLS_HANDSHAKE_FAILED
                Debug.Print "TLS negotiation failed"
            Case ERR_HANDSHAKE_REJECTED
                Debug.Print "Server rejected WebSocket upgrade"
            Case ERR_PROXY_AUTH_FAILED
                Debug.Print "Proxy credentials rejected"
            Case ERR_MAX_CONNECTIONS
                Debug.Print "Connection pool full"
            Case Else
                Debug.Print "Unexpected error:", WebSocketGetLastError(h)
        End Select

        Debug.Print "System code:", WebSocketGetLastErrorCode(h)
        Debug.Print "Details:", WebSocketGetTechnicalDetails(h)
        Exit Sub
    End If

    Debug.Print "Connected successfully"
End Sub

Complete Error Reference

ERR_NONE (0)

No error occurred. The operation completed successfully.

ERR_WSA_STARTUP_FAILED (1)

What happened: WSAStartup returned a non-zero value. The Winsock subsystem could not be initialized.

Common causes:

What to check:

' Example error output
' Error: 1
' System code: 10091
' Details: WSAStartup failed with code 10091

ERR_SOCKET_CREATE_FAILED (2)

What happened: The socket() function returned INVALID_SOCKET. A TCP socket could not be allocated.

Common causes:

What to check:

' Example error output
' Error: 2
' System code: 10024
' Details: socket() failed with WSA error 10024

[!NOTE] WSA error 10024 means WSAEMFILE (too many open sockets).

ERR_DNS_RESOLVE_FAILED (3)

What happened: gethostbyname() could not resolve the hostname to an IP address.

Common causes:

System codes and their meaning:

WSA Code Name Meaning
11001 WSAHOST_NOT_FOUND The hostname does not exist in DNS
11002 WSATRY_AGAIN Temporary DNS failure, try again later
11003 WSANO_RECOVERY Non-recoverable DNS error
11004 WSANO_DATA Hostname exists but has no IP address record

What to check:

' Example error output
' Error: 3
' System code: 11001
' Details: gethostbyname() failed for 'bad.hostname.example' with WSAHOST_NOT_FOUND (11001)

[!TIP] If you see error 11002, wait a moment and try again. This is typically a transient DNS issue that resolves itself.

ERR_CONNECT_FAILED (4)

What happened: The TCP connection could not be established. Either connect() failed immediately or select() timed out waiting for the connection to complete. This includes failures from the Happy Eyeballs dual‑stack connection process.

Common causes:

What to check:

' Example error output
' Error: 4
' System code: 10060
' Details: Connect failed: WSAETIMEDOUT - Connection timed out

[!NOTE] WSA error 10060 means WSAETIMEDOUT. WSA error 10061 means WSAECONNREFUSED (server actively refused the connection).

ERR_TLS_ACQUIRE_CREDS_FAILED (5)

What happened: AcquireCredentialsHandle could not initialize the Schannel security provider.

Common causes:

What to check:

' Example error output
' Error: 5
' System code: -2146893043
' Details: AcquireCredentialsHandle failed: 0x8009030D

ERR_TLS_HANDSHAKE_FAILED (6)

What happened: InitializeSecurityContext returned a fatal error during the TLS handshake.

Common causes:

What to check:

' Example error output
' Error: 6
' System code: -2146893018
' Details: TLS handshake failed: 0x80090326

[!WARNING] SSPI error 0x80090326 means SEC_E_ILLEGAL_MESSAGE. This often indicates a middlebox (corporate proxy or firewall) is intercepting and corrupting TLS traffic.

ERR_TLS_HANDSHAKE_TIMEOUT (7)

What happened: The TLS handshake did not complete within the allowed time or iteration limit.

Common causes:

What to check:

' Example error output
' Error: 7
' System code: 0
' Details: TLS handshake timed out with api.example.com

ERR_WEBSOCKET_HANDSHAKE_FAILED (8)

What happened: Wasabi could not send or receive the HTTP upgrade request that initiates the WebSocket connection.

Common causes:

What to check:

' Example error output
' Error: 8
' System code: 10054
' Details: recv() WS handshake failed: WSAECONNRESET - Connection reset by peer

[!NOTE] WSA error 10054 means WSAECONNRESET (connection reset by peer).

ERR_WEBSOCKET_HANDSHAKE_TIMEOUT (9)

What happened: The server did not respond to the HTTP upgrade request within the timeout period.

Common causes:

What to check:

' Example error output
' Error: 9
' System code: 0
' Details: No WS handshake response within 5s

ERR_SEND_FAILED (10)

What happened: A send() call returned zero or negative after attempting to write data to the socket.

Common causes:

What to check:

' Example error output
' Error: 10
' System code: 10054
' Details: send() failed: WSAECONNRESET - Connection reset by peer

ERR_RECV_FAILED (11)

What happened: A recv() call returned a negative value.

Common causes:

What to check:

ERR_NOT_CONNECTED (12)

What happened: A send operation was attempted on a handle that is not currently connected.

Common causes:

What to check:

' Safe send pattern
If WebSocketIsConnected(h) Then
    WebSocketSend "data", h
Else
    Debug.Print "Not connected"
End If

ERR_ALREADY_CONNECTED (13)

Reserved for future use.

ERR_TLS_ENCRYPT_FAILED (14)

What happened: EncryptMessage returned a non-zero SSPI status code. The outgoing data could not be encrypted.

Common causes:

What to check:

ERR_TLS_DECRYPT_FAILED (15)

What happened: DecryptMessage returned a fatal error other than SEC_I_RENEGOTIATE (which is handled separately by ERR_TLS_RENEGOTIATE).

Common causes:

What to check:

ERR_INVALID_URL (16)

What happened: The URL could not be parsed.

Common causes:

What to check:

' Valid URLs
WebSocketConnect "ws://localhost/chat"
WebSocketConnect "wss://api.example.com/ws"
WebSocketConnect "wss://api.example.com:8443/stream"

' Invalid URLs
WebSocketConnect "http://example.com"       ' wrong scheme
WebSocketConnect "wss://"                    ' missing host
WebSocketConnect "wss://host:abc/path"       ' non-numeric port
WebSocketConnect "wss://host:99999/path"     ' port out of range

ERR_HANDSHAKE_REJECTED (17)

What happened: The server responded to the HTTP upgrade request with a status code other than 101, or the Sec-WebSocket-Accept header value did not match the expected SHA-1 hash.

Common causes:

What to check:

' Example error output
' Error: 17
' System code: 0
' Details: WebSocket upgrade rejected. Server response: HTTP/1.1 403 Forbidden

[!TIP] The technical details string includes the server’s HTTP status line, which is often enough to diagnose the issue without external tools.

ERR_CONNECTION_LOST (18)

What happened: The connection was lost during normal operation. This can be triggered by recv() returning zero (clean server close), ioctlsocket failing, or an oversized frame being received.

Common causes:

What to check:

' Resilient connection pattern
WebSocketSetAutoReconnect True, 10, 2000, h
WebSocketSetPingInterval 25000, h

ERR_INVALID_HANDLE (19)

What happened: The handle passed to a function is outside the valid range (0 to 63).

Common causes:

What to check:

ERR_MAX_CONNECTIONS (20)

What happened: All 64 slots in the connection pool are occupied.

Common causes:

What to check:

' Audit active connections
Dim handles() As Long
Dim i As Long

handles = WebSocketGetAllHandles()

Debug.Print "Active connections:", WebSocketGetConnectionCount()
For i = LBound(handles) To UBound(handles)
    Debug.Print "Handle", handles(i), _
                "Host:", WebSocketGetHost(handles(i)), _
                "Uptime:", WebSocketGetUptime(handles(i)), "s"
Next i

ERR_PROXY_CONNECT_FAILED (21)

What happened: The HTTP CONNECT request to the proxy server failed. Either the send() to the proxy failed, the proxy did not respond, or the proxy response could not be read.

Common causes:

What to check:

ERR_PROXY_AUTH_FAILED (22)

What happened: The proxy returned HTTP 407 (Proxy Authentication Required) or the SOCKS5 authentication handshake failed.

Common causes:

What to check:

[!NOTE] Wasabi supports HTTP Basic and NTLM/Kerberos (via WebSocketSetProxyNtlm) for HTTP proxies. For SOCKS5, only username/password authentication is available.

ERR_PROXY_TUNNEL_FAILED (23)

What happened: The proxy accepted the connection but returned a non-200 status for the CONNECT tunnel request.

Common causes:

What to check:

' Example error output
' Error: 23
' System code: 0
' Details: Proxy CONNECT rejected: HTTP/1.1 403 Forbidden

ERR_INACTIVITY_TIMEOUT (24)

What happened: No data was received from the server within the configured inactivity timeout period.

Common causes:

What to check:

' Recommended resilient configuration
WebSocketSetInactivityTimeout 60000, h
WebSocketSetPingInterval 25000, h
WebSocketSetAutoReconnect True, 5, 2000, h

[!TIP] Combining WebSocketSetInactivityTimeout with WebSocketSetPingInterval and WebSocketSetAutoReconnect creates the most resilient connection configuration available in Wasabi.

ERR_CERT_LOAD_FAILED (25)

What happened: Wasabi failed to load a client certificate from a PFX file or the Windows certificate store. The certificate was configured via WebSocketSetClientCert or WebSocketSetClientCertPfx but could not be found, imported, or parsed.

Common causes:

What to check:

' Example error output
' Error: 25
' System code: 0
' Details: PFX file not found: C:\certs\client.pfx

[!NOTE] If client certificate loading fails, Wasabi will continue the connection without a client certificate and log a warning. The server may then reject the TLS handshake if mTLS is required.

ERR_CERT_VALIDATE_FAILED (26)

What happened: Server certificate validation was enabled (WebSocketSetCertValidation True) and the chain verification failed.

Common causes:

What to check:

ERR_FRAGMENT_OVERFLOW (27)

What happened: A fragmented WebSocket message grew larger than the configured FragmentBuffer size.

The received continuation frames accumulated a payload that exceeded the buffer capacity. The connection is closed to prevent memory corruption.

Common causes:

What to check:

' Increasing the fragment buffer to 1 MB
WebSocketSetBufferSizes 262144, 1048576, h

ERR_TLS_RENEGOTIATE (28)

What happened: The server requested a TLS renegotiation after the initial handshake was complete. Wasabi does not support renegotiation and closes the connection.

Common causes:

What to check:

[!NOTE] Wasabi intentionally does not implement TLS renegotiation due to the complexity of handling it correctly in single-threaded VBA. Auto reconnect is the recommended recovery mechanism.

Quick Diagnostic Checklist

When a connection fails, run through this list in order.

Step Check How
1 Is the URL valid? Verify scheme, host, port, and path
2 Can you reach the host? Ping the hostname from a command prompt
3 Is DNS resolving? Try using an IP address instead of hostname
4 Is a proxy required? Check with your network administrator
5 Is TLS the issue? Try ws:// instead of wss:// to isolate
6 Is the path correct? Verify the WebSocket endpoint with a browser tool
7 Are headers required? Check if the server needs Authorization or other headers
8 What did the server say? Read WebSocketGetTechnicalDetails for the server response
9 Is the pool full? Check WebSocketGetConnectionCount
10 Is auto reconnect working? Check WebSocketGetReconnectInfo

Common WSA Error Codes

These are the most frequently encountered Winsock error codes in Wasabi diagnostic output.

Code Name Meaning
10035 WSAEWOULDBLOCK Operation would block (normal for non-blocking sockets)
10038 WSAENOTSOCK Socket handle is not valid
10053 WSAECONNABORTED Connection aborted by local software
10054 WSAECONNRESET Connection reset by remote host
10060 WSAETIMEDOUT Connection timed out
10061 WSAECONNREFUSED Connection actively refused by target
11001 WSAHOST_NOT_FOUND Hostname does not exist
11002 WSATRY_AGAIN Temporary DNS failure
11003 WSANO_RECOVERY Non-recoverable DNS error
11004 WSANO_DATA Hostname valid but no IP address available

Common SSPI Error Codes

These are the most frequently encountered Schannel/SSPI error codes.

Code (hex) Name Meaning
0x80090300 SEC_E_INSUFFICIENT_MEMORY Not enough memory for security operation
0x80090304 SEC_E_INTERNAL_ERROR Internal Schannel error
0x80090305 SEC_E_NOT_OWNER Caller does not own the credentials
0x8009030D SEC_E_UNKNOWN_CREDENTIALS Credentials not recognized
0x80090311 SEC_E_NO_AUTHENTICATING_AUTHORITY No authority could be contacted for authentication
0x80090318 SEC_E_INCOMPLETE_MESSAGE Received TLS record is incomplete (internal, handled by Wasabi)
0x80090326 SEC_E_ILLEGAL_MESSAGE Received message is corrupted or unexpected
0x00090312 SEC_I_CONTINUE_NEEDED Handshake needs more data (internal, handled by Wasabi)
0x00090321 SEC_I_RENEGOTIATE Server requested TLS renegotiation (now handled as ERR_TLS_RENEGOTIATE)