Web socket subscriptions are not working

Question from Discord:

hey there, can any1 guide me on why I constantly get Subscription only supported by WebSocket client?
have tried different nodes and idk what to do, it’s 1:1 with examples provided in sui repo

use futures::stream::StreamExt;
use sui_json_rpc_types::EventFilter;
use sui_sdk::{
    types::base_types::SuiAddress,
    SuiClientBuilder,
};
use std::str::FromStr;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let ws = SuiClientBuilder::default()
        .ws_url("add ur wss uri")
        .build("add ur node uri")
        .await?;
    
    let address = SuiAddress::from_str("add ur addr here")?;
    println!("monitoring txns for address: {:?}", address);

    let mut sub = match ws
        .event_api()
        .subscribe_event(EventFilter::Sender(address.clone()))
        .await
    {
        Ok(subscription) => subscription,
        Err(e) => {
            eprintln!("subscription error: {:?}", e);
            eprintln!("ensure the WebSocket endpoint supports subscriptions.");
            return Ok(());
        }
    };

    println!("started monitoring txns for address: {}", address);

    while let Some(transaction) = sub.next().await {
        match transaction {
            Ok(tx) => {
                println!("tx: {:#?}", tx);
            }
            Err(e) => {
                eprintln!("error receiving tx: {}", e);
            }
        }
    }

    Ok(())
}

Web socket subscriptions are not supported by all FNs (and the mechanism is largely deprecated at this time) so perhaps the FN you interacting with does not support it. They are quite labor intensive so most public nodes don’t have web sockets enabled. Having said that, the team is working on updating the subscription mechanism. Until then, I would suggest going with a event querying approach.