-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Comments
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> |
I'm sorry, accidentally turned it close, I don't know if you can turn it open again? |
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. If this doesn't solve your problem, I'll check on a Windows XP VM with IE9 installed. |
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:
Expected behavior
hope to support IE9.
Versions (please complete the following information):
Additional context
on IE9 browser (not support websocket)
The text was updated successfully, but these errors were encountered: