On Thu, 06 Jun 2024 13:39:59 GMT, Sönke Ludwig wrote:

On Tue, 04 Jun 2024 15:35:21 GMT, MrX wrote:

On Tue, 04 Jun 2024 15:33:51 GMT, MrX wrote:

On Tue, 04 Jun 2024 08:58:05 GMT, Sönke Ludwig wrote:

On Tue, 28 May 2024 12:19:26 GMT, MrX wrote:


Could someone share an example on how to execute a ping/pong through a WebSocket?

Thank you.

Since there a similar ticket just popped up, in case this is actually meant to send a low-level ping/pong on the web socket protocol level, this might be relevant: https://github.com/vibe-d/vibe.d/issues/2802


This does not work:
source/app.d(30,17): Error: class vibe.http.websockets.OutgoingWebSocketMessage constructor this is not accessible
source/app.d(39,32): Error: none of the overloads of write are callable using argument types ()

Do you have an example that works?

Sorry receiver.send((message) { message.write([]); }, FrameOpcode.ping); typo fix.

The following compiles and runs successfully for me, the explicit OutgoingWebSocketMessage construction wasn't being used and could just be removed. The remaining error was caused by .write having two overloads (const(char)[] and const(ubyte)[]) that were ambiguous:

import vibe.core.core;
import vibe.core.log;
import vibe.http.fileserver : serveStaticFiles;
import vibe.http.router : URLRouter;
import vibe.http.server;
import vibe.http.websockets;
import vibe.inet.url;
import core.time;

int main(string[] args)
    string WS_URL= "wss://echo.websocket.org";
    auto ws_url = URL(WS_URL);
    const use_tls = (ws_url.schema == "wss" || ws_url.schema == "https") ? true : false;
    ws_url.schema = use_tls ? "https" : "http";
    auto receiver = connectWebSocket(ws_url);
    while (receiver.waitForData())
            logInfo("GOT: %s", receiver.receiveText());
            try {
                    receiver.send((message) { message.write(""); }, FrameOpcode.ping);
            catch (Exception ex) {
                logInfo("error %s", ex.msg);

    return 0;

This works! Thanks.