Last modified: 2014-07-13 22:55:22 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)
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; }