This guide provides detailed steps to enable and use debug logs to troubleshoot your Waku DApp, whether in a NodeJS or browser environment and check your WebSocket connections in nwaku.
Enabling debug logs
When resolving issues in your Waku DApp, debug logs can be helpful. The
libp2p packages use the debug tool to handle and show logs that help you debug effectively.
To enable debug logs for
@waku/sdk on NodeJS, you must set the
DEBUG environment variable. To only enable debug logs for
To enable debug logs for both
To enable debug logs for all components:
To view debug logs in your browser's console, modify the local storage and add the
debug key. Here are guides for various modern browsers:
@waku/sdk debug logs
libp2p debug logs
|Enables all debug logs
Checking WebSocket setup
It's important to note that browsers impose certain limitations on WebSocket usage:
- Secure Context Requirement: Insecure subroutines are prohibited in secure contexts. On an
wssconnections are permitted, while
wsconnections are not allowed. This restriction does not apply if the webpage is served locally, like on
- Certificate Validation: Certificate validation rules are consistent for
wssconnections. Certificates must not be expired, issued by a recognized Certificate Authority (CA), and match the domain name, among other criteria.
- User Feedback on Errors: Web browsers do not display errors related to subroutines to the user. If a WebSocket connection encounters an issue, users won't be alerted directly; you'll need to check the browser's console for error details.
If you encounter difficulties when connecting to a remote node using
wss, follow these steps:
Try Websocat for connection
Attempt to connect using websocat, a tool for WebSocket interactions. Test the WebSocket port using the command:
websocat -v wss://[WEBSOCKET HOST]:[WEBSOCKET PORT]
For example, consider a
nwaku node with the multiaddr as
$ websocat -v wss://nwakunode.com:1234
[INFO websocat::ws_client_peer] Connected to ws
The connection works if the
[INFO websocat::ws_client_peer] Connected to ws log entry appears. If not, check that the certificate is valid
Check certificate validity
Verify the certificate's validity by passing the
--insecure flag to handle invalid certificates in
websocat -v -k wss://nwakunode.com:1234
If this works, the certificate's invalidity is the problem, and you should investigate the cause of the error if not, check if the WebSocket port is accessible.
Check WebSocket port accessibility
telnet or another networking tool to verify if the WebSocket port is open and accessible. For example, if the multiaddr is
/dns4/nwakunode.com/tcp/1234/wss/p2p/16..., use the command:
$ telnet nwakunode.com 1234
Connected to nwakunode.com.