socketioxide icon indicating copy to clipboard operation
socketioxide copied to clipboard

This library does not seem to support IE9.

Open wwstory opened this issue 1 year ago • 4 comments

Describe the bug However, for the official nodejs language version of socketio (server side, latest version: 4.7), it can be used normally on IE9 (socketio version 3.0.5, for client, the latest version doesn't seem to work).

To Reproduce Steps to reproduce the behavior:

  1. rust for server
  2. js for client (IE9, use socketio version 3.0.5 ~ 4.7.5)
  3. for echo example, unable to successfully send or receive messages.

Expected behavior hope to support IE9.

Versions (please complete the following information):

  • Socketioxide version: 0.14.0
  • axum version: 0.7.5
  • Socket.io client version: IE9 browser

Additional context on IE9 browser (not support websocket)

wwstory avatar Aug 07 '24 08:08 wwstory

If anyone want to verify this issue and provide a minimal reproducible example it would help greatly.

Totodore avatar Jan 01 '25 18:01 Totodore

If anyone want to verify this issue and provide a minimal reproducible example it would help greatly.

the previous test was unsuccessful, and the task was implemented using the nodejs version of socketio.

this is my test code:

use serde_json::Value;
use socketioxide::{
    extract::{AckSender, Bin, Data, SocketRef},
    SocketIo,
};
use tower::ServiceBuilder;
use tower_http::cors::CorsLayer;
// use tracing::info;
use tracing_subscriber::FmtSubscriber;

fn on_connect(socket: SocketRef, Data(data): Data<Value>) {
    println!("Socket.IO connected: {:?} {:?}", socket.ns(), socket.id);
    socket.emit("connect", data).ok();

    socket.on(
        "message",
        |socket: SocketRef, Data::<Value>(data), Bin(bin)| {
            println!("Received event: {:?} {:?}", data, bin);
            println!("-3 message");
            socket.bin(bin).emit("message-back", data).ok();
        },
    );

    socket.on(
        "message-with-ack",
        |Data::<Value>(data), ack: AckSender, Bin(bin)| {
            println!("Received event: {:?} {:?}", data, bin);
            ack.bin(bin).send(data).ok();
        },
    );
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing::subscriber::set_global_default(FmtSubscriber::default())?;

    let (layer, io) = SocketIo::new_layer();

    io.ns("/", on_connect);
    io.ns("/custom", on_connect);

    // let app = axum::Router::new()
    //     .route("/", get(|| async { "Hello, World!" }))
    //     .layer(layer);

    // info!("Starting server");

    // let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    // axum::serve(listener, app).await.unwrap();

    // Ok(())

    let app = axum::Router::new().layer(
        ServiceBuilder::new()
            .layer(CorsLayer::permissive()) // Enable CORS policy
            .layer(layer),
    );

    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    println!("start server...");
    axum::serve(listener, app).await.unwrap();

    Ok(())
}
[package]
name = "demo_socketio"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.7.5"
serde_json = "1.0.122"
socketioxide = { version = "0.14.0" }
tokio = { version = "1.39.2", features = ["rt-multi-thread", "macros"] }
tower = "0.4.13"
tower-http = { version = "0.5.2", features = ["cors"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"

<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Test</title>
</head>

<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="https://cdn.socket.io/3.0.5/socket.io.min.js"
    integrity="sha384-c79GN5VsunZvi+Q/WObgk2in0CbZsHnjEqvFxC5DxHn9lTfNce2WW6h2pH6u/kF+"
    crossorigin="anonymous"></script>
<script>
    var socket;
    function connect1() {
        var url = $("#url").val();
        console.log(url);
        socket = io(url);

        // Initialize variables
        document.getElementById('btn1').addEventListener('click', function (event) {
            socket.emit('message', '-1 message');
        });
        document.getElementById('btn2').addEventListener('click', function (event) {
            socket.emit('message-with-ack', '-message-with');
        });

        // Socket events

        // Whenever the server emits 'new message', update the chat body
        socket.on('connect', function (data) {
            console.log("connect:::", data);
        });

        socket.on('message', function (data) {
            console.log("-1 message", data);
            socket.emit('message', '-2 message');
        });

        socket.on('message-back', function (data) {
            console.log("-4 message-back", data);
        });

        socket.on('disconnect', function () {
            console.log('you have been disconnected');
        });

        socket.io.on('reconnect', function () {
            console.log('you have been reconnected');
            socket.emit('reconnect2', 'reconnect22222');
        });

        socket.io.on('reconnect_error', function () {
            console.log('attempt to reconnect has failed');
        });

    }
</script>

<body>
    <input id="url" type="text" value="http://localhost:3000">
    <button id="btn_connect" onclick="connect1()">connect</button><br />
    <button id="btn1">test1</button><br />
    <button id="btn2">test2</button><br />
</body>

</html>

wwstory avatar Feb 21 '25 10:02 wwstory

I'm sorry, accidentally turned it close, I don't know if you can turn it open again?

wwstory avatar Feb 21 '25 10:02 wwstory

The example you provided is working well with IE11 (with the edge compatibility mode). The only issue is that the integrity key is wrong and prevents the socket.io client lib to load. If you remove it, it works. <script src="https://cdn.socket.io/3.0.5/socket.io.min.js" integrity="sha384-c79GN5VsunZvi+Q/WObgk2in0CbZsHnjEqvFxC5DxHn9lTfNce2WW6h2pH6u/kF+" crossorigin="anonymous"></script>.

If this doesn't solve your problem, I'll check on a Windows XP VM with IE9 installed.

Totodore avatar Mar 01 '25 09:03 Totodore

Closing because of inactivity. If anyone still has an issue with IE9, re-open an issue, with a full reproducible example with traces and logs.

Totodore avatar Oct 10 '25 20:10 Totodore