Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

al.mootasem's avatar

Connecting to a signalr websocket server with a PHP client?

I'm trying to figure out a way to use Bittrex's WebSocket to subscribe and recieve real time data from my PHP Laravel project. On their documintation they only talk about available methods, nothing about how to establish a connection.

My knowledge in WebSockets is very limited, however, I managed to connect to Kraken's WebSockets before like so:

const socket = new WebSocket('wss://ws.kraken.com');
const pairs = [
    //a list of asset pairs available on Kraken
];

const subscription = {
    "event": "subscribe",
    "pair": pairs,
    "subscription": {
        "name": "ticker"
    }
}
// Connection opened
socket.addEventListener('open', function (event) {
    socket.send(JSON.stringify(subscription));
});


//Somewhere else in the code
socket.addEventListener('message', (event) => {
    const data = JSON.parse(event.data);
});

What confuses me is Url on Bittrex, it's: https://socket.bittrex.com/signalr (it starts with https as you can see) while on Kraken it is: wss://ws.kraken.com (wss, which is the correct format as far as my knowledge goes)

I've tried to connect to Bittrex same way as I did with Kraken, and also tried with PHP using this https://github.com/ratchetphp/Pawl, but both fail with an error about an invalid url which drives me to think that they work in an entirely different ways.

I feel like I'm missing something and that I don't even know what am I looking for, any help pointing me to the right direction on what to research is appreciated guys.

Thanks all!

0 likes
0 replies

Please or to participate in this conversation.