Last modified: 2014-07-13 22:55:22 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T69955, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 67955 - Stream: Websocket client fails on ws://stream.wikimedia.org/rc: HTTP/1.1 404 Not Found
Stream: Websocket client fails on ws://stream.wikimedia.org/rc: HTTP/1.1 404 ...
Status: NEW
Product: Wikimedia
Classification: Unclassified
Stream (Other open bugs)
wmf-deployment
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-07-13 19:48 UTC by Merlijn van Deen (test)
Modified: 2014-07-13 22:55 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Merlijn van Deen (test) 2014-07-13 19:48:23 UTC
using https://github.com/dhbaird/easywsclient , with the URL adapted to

ws = WebSocket::from_url("ws://stream.wikimedia.org/rc");

results in 

easywsclient: connecting: host=stream.wikimedia.org port=80 path=/rc
ERROR: Got bad status connecting to ws://stream.wikimedia.org/rc: HTTP/1.1 404 Not Found


which is distinct from Bug 66989 (which uses a socketio specific library, and which reports 502's)
Comment 1 Merlijn van Deen (test) 2014-07-13 22:55:22 UTC
Okay, this seems to be because of Socket.IO. Basically, it's not possible to connect using plain websockets, as there's some opaque (and non-documented!!) protocol above it.

How to connect using websockets:

1) Go to http://stream.wmflabs.org/socket.io/1/. Copy the first integer.
2) Use ws://stream.wmflabs.org/socket.io/1/websocket/<that integer> as websockets URL
3) Don't forget to reply to pings!


The following code sort-of works using the library linked in #0:

#include "easywsclient.hpp"
#include <iostream>
#include <cstdlib>
#include <assert.h>
#include <stdio.h>
#include <string>

using easywsclient::WebSocket;
static WebSocket::pointer ws = NULL;

void handle_message(const std::string & message)
{
    printf(">>> %s\n", message.c_str());
    if (message == "world") { ws->close(); }
}

int main(int argc, char *argv[])
{
    if (argc != 2) {
        std::cout << "ERROR: must provide WS url; use the following:\n"
                  << argv[0] << " ws://stream.wmflabs.org/socket.io/1/websocket/`curl http://stream.wmflabs.org/socket.io/1/ | cut -d: -f1`\n";
        exit(1);
    }
    ws = WebSocket::from_url(argv[1]);
    assert(ws);
    ws->send("5::/rc:{\"name\": \"subscribe\", \"args\": [\"*\"]}");
    ws->send("hello");
    while (ws->getReadyState() != WebSocket::CLOSED) {
      ws->poll();
      ws->dispatch(handle_message);
    }
    delete ws;
    return 0;
}

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links