Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This library does not seem to support IE9. #355

Open
wwstory opened this issue Aug 7, 2024 · 4 comments
Open

This library does not seem to support IE9. #355

wwstory opened this issue Aug 7, 2024 · 4 comments
Labels
A-engineioxide Area related to engineioxide C-Bug Something isn't working E-Easy Call for participation: Experience needed to fix: Easy / not much E-Need-MCVE Call for participation: This issue needs a Minimal Complete and Verifiable Example P-High High priority

Comments

@wwstory
Copy link

wwstory commented Aug 7, 2024

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 wwstory added the C-Bug Something isn't working label Aug 7, 2024
@Totodore Totodore added A-engineioxide Area related to engineioxide P-High High priority E-Easy Call for participation: Experience needed to fix: Easy / not much E-Need-MCVE Call for participation: This issue needs a Minimal Complete and Verifiable Example labels Jan 1, 2025
@Totodore
Copy link
Owner

Totodore commented Jan 1, 2025

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

@Totodore Totodore added this to Roadmap Jan 1, 2025
@Totodore Totodore moved this to Todo in Roadmap Jan 1, 2025
@Totodore Totodore removed their assignment Jan 1, 2025
@wwstory wwstory closed this as completed Feb 21, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Feb 21, 2025
@wwstory
Copy link
Author

wwstory commented Feb 21, 2025

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
Copy link
Author

wwstory commented Feb 21, 2025

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

@Totodore Totodore reopened this Feb 21, 2025
@Totodore Totodore moved this from Done to In Progress in Roadmap Mar 1, 2025
@Totodore
Copy link
Owner

Totodore commented Mar 1, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-engineioxide Area related to engineioxide C-Bug Something isn't working E-Easy Call for participation: Experience needed to fix: Easy / not much E-Need-MCVE Call for participation: This issue needs a Minimal Complete and Verifiable Example P-High High priority
Projects
Status: In Progress
Development

No branches or pull requests

2 participants