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

EngineIO Panic #166

Closed
mawoka-myblock opened this issue Mar 13, 2022 · 46 comments
Closed

EngineIO Panic #166

mawoka-myblock opened this issue Mar 13, 2022 · 46 comments

Comments

@mawoka-myblock
Copy link

I a using your great library, but my applications panics after some time (seems to be random ~10-30 secs after startup) with the following backtrace:

thread '<unnamed>' panicked at 'EngineIO Error', /home/mawoka/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_socketio-0.3.0/src/client/builder.rs:229:21
stack backtrace:
   0:     0x557646368a8c - std::backtrace_rs::backtrace::libunwind::trace::hd70f18a67bf1064d
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x557646368a8c - std::backtrace_rs::backtrace::trace_unsynchronized::hed700f39aaa9560e
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x557646368a8c - std::sys_common::backtrace::_print_fmt::h05ffc8c800d3fd6e
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x557646368a8c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc3335dc9ac9ea141
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x5576463904dc - core::fmt::write::h8ba7e47d56fb9287
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/core/src/fmt/mod.rs:1190:17
   5:     0x557646362018 - std::io::Write::write_fmt::hcc4602e4a7d8cb4e
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/io/mod.rs:1657:15
   6:     0x55764636ace7 - std::sys_common::backtrace::_print::hfefb27db9027fc13
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x55764636ace7 - std::sys_common::backtrace::print::h3b5c5f5af201c47a
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x55764636ace7 - std::panicking::default_hook::{{closure}}::h9364b8e096329e42
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:295:22
   9:     0x55764636a99f - std::panicking::default_hook::hbb3fd2f25c08d7b9
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:314:9
  10:     0x55764636b43b - std::panicking::rust_panic_with_hook::hb8806bff47a676e3
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:698:17
  11:     0x55764636b127 - std::panicking::begin_panic_handler::{{closure}}::h9d9d57a8e207ec62
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:588:13
  12:     0x557646368f54 - std::sys_common::backtrace::__rust_end_short_backtrace::h41203f137e127a88
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x55764636ae39 - rust_begin_unwind
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:584:5
  14:     0x557645918b73 - core::panicking::panic_fmt::h472b827f82d8bfa4
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/core/src/panicking.rs:142:14
  15:     0x557645b4c104 - core::panicking::panic_display::h2419126f417c20d1
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/core/src/panicking.rs:73:5
  16:     0x557645b4585a - rust_socketio::client::builder::ClientBuilder::connect::{{closure}}::h887cc7cd172ebccc
                               at /home/mawoka/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_socketio-0.3.0/src/client/builder.rs:229:21
  17:     0x557645b53310 - std::sys_common::backtrace::__rust_begin_short_backtrace::haf4ad59f77837423
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys_common/backtrace.rs:122:18
  18:     0x557645b3ed4d - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h9fc04ac80e2aa3df
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/thread/mod.rs:498:17
  19:     0x557645b3d991 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h013c64b8db9e80d3
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/core/src/panic/unwind_safe.rs:271:9
  20:     0x557645b4c439 - std::panicking::try::do_call::h5e086d5aed2793f2
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:492:40
  21:     0x557645b4c8eb - __rust_try
  22:     0x557645b4c371 - std::panicking::try::h1cf7f936c2d9e65d
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panicking.rs:456:19
  23:     0x557645b3d491 - std::panic::catch_unwind::h3e2a3829123712dc
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/panic.rs:137:14
  24:     0x557645b3eb57 - std::thread::Builder::spawn_unchecked_::{{closure}}::h9f4f924223a945bc
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/thread/mod.rs:497:30
  25:     0x557645b4431f - core::ops::function::FnOnce::call_once{{vtable.shim}}::hfa8076f56c9bb1ad
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/core/src/ops/function.rs:227:5
  26:     0x557646371163 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h78e3a4498542e3c1
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/alloc/src/boxed.rs:1854:9
  27:     0x557646371163 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h350da154130e2756
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/alloc/src/boxed.rs:1854:9
  28:     0x557646371163 - std::sys::unix::thread::Thread::new::thread_start::h918df3b0ffbb0232
                               at /rustc/68369a041cea809a87e5bd80701da90e0e0a4799/library/std/src/sys/unix/thread.rs:108:17
  29:     0x7fc67ed715c2 - start_thread
  30:     0x7fc67edf6584 - __clone
  31:                0x0 - <unknown>

It's probably just me, doing something completely wrong, but I think that it still shouldn't panic.

Thanks for your help!

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 14, 2022

Hey ;) Thanks for using the library! Could you maybe give more information on your Client and Server setup? I can't really find something from the stack trace that gives a clear indication of what went wrong, besides the fact that it happened during connection. Generally I would think that has something to do with the underlying network connection.
Also are you sure that the server is running the correct socket.io protocol revision (revision 5 of the socket.io protocol)?

@mawoka-myblock
Copy link
Author

Hey ;) Thanks for using the library! Could you maybe give more information on your Client and Server setup? I can't really find something from the stack trace that gives a clear indication of what went wrong, besides the fact that it happened during connection. Generally I would think that has something to do with the underlying network connection. Also are you sure that the server is running the correct socket.io protocol revision (revision 5 of the socket.io protocol)?

I am using the python-implementation with FastAPI (asgi-mount), which works perfectly fine in production. The Python-client also doesn't crash with this server. An unstable connection can't be possible because of local host. In the next days I'll try the same thing with the js-client and see if the error also occurs there. By the way: until it panicks, it works perfectly fine.

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 14, 2022

Oke, I tried to setup a local example and used the following code which ran through all right:

Server:

from fastapi import FastAPI
from fastapi_socketio import SocketManager

app = FastAPI()
sio = SocketManager(app=app, cors_allowed_origins=["*"], mount_location='/')


@app.sio.on('join')
async def handle_join(sid, *args, **kwargs):
    await sio.emit('lobby', 'User joined')


@sio.on('test')
async def test(sid, *args, **kwargs):
    await sio.emit('hey', 'joe')



if __name__ == '__main__':
    import logging
    import sys

    logging.basicConfig(level=logging.DEBUG,
                        stream=sys.stdout)

    import uvicorn

    uvicorn.run("foo:app", host='0.0.0.0', port=4200, reload=True, debug=False)

Client:

fn main() -> Result<(), Error> {
    let url = Url::parse("http://localhost:4200/socket.io/").unwrap();

    let socket = ClientBuilder::new(url)
        .on("hey", |msg, _| match msg {
            Payload::String(str) => println!("Received string: {}", str),
            Payload::Binary(bin) => println!("Received binary data: {:#?}", bin
        })
        .connect()?;

    let payload = json!({"token": 123});
    let result = socket.emit("test", Payload::String(payload.to_string()));

    assert!(result.is_ok());

    sleep(Duration::from_secs(2));

    assert!(socket.disconnect().is_ok());
    Ok(())
}

I don't know how confidential your code is, but if you struggle to find the error don't mind sending me the code via mail ;)

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 14, 2022

The code is over here: https://github.com/mawoka-myblock/sd-replacement/tree/rewrite. The code producing the error is located in the rust-client-executor.

@mawoka-myblock
Copy link
Author

The Dart-client doesn't have these problems.

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 19, 2022

The problem is still there, also if I use your example, but now the stacktrace is empty.

Rust: rustc 1.61.0-nightly

I've also tried the stable compiler, same problem.

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

I am sorry but the executor code doesn't even compile:

error[E0599]: no method named `press` found for enum `public::KeybdKey` in the current scope
   --> ../.cargo/registry/src/github.com-1ecc6299db9ec823/inputbot-0.5.1/src/public.rs:217:41
    |
10  | pub enum KeybdKey {
    | ----------------- method `press` not found for this
...
217 |                     KeybdKey::LShiftKey.press();
    |                                         ^^^^^ method not found in `public::KeybdKey`

error[E0599]: no method named `press` found for enum `public::KeybdKey` in the current scope
   --> .../.cargo/registry/src/github.com-1ecc6299db9ec823/inputbot-0.5.1/src/public.rs:219:27
    |
10  | pub enum KeybdKey {
    | ----------------- method `press` not found for this
...
219 |                 keybd_key.press();
    |                           ^^^^^ method not found in `public::KeybdKey`

error[E0599]: no method named `release` found for enum `public::KeybdKey` in the current scope
   --> .../.cargo/registry/src/github.com-1ecc6299db9ec823/inputbot-0.5.1/src/public.rs:221:27
    |
10  | pub enum KeybdKey {
    | ----------------- method `release` not found for this
...
221 |                 keybd_key.release();
    |                           ^^^^^^^ method not found in `public::KeybdKey`

error[E0599]: no method named `release` found for enum `public::KeybdKey` in the current scope
   --> ../.cargo/registry/src/github.com-1ecc6299db9ec823/inputbot-0.5.1/src/public.rs:223:41
    |
10  | pub enum KeybdKey {
    | ----------------- method `release` not found for this
...
223 |                     KeybdKey::LShiftKey.release();
    |                                         ^^^^^^^ method not found in `public::KeybdKey`

```�

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 19, 2022

I've seen and fixed it, so that wasn't the problem. Added some imports and the one ), but the problem is still there.

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Also my example still runs fine. What compiler version are you on? (running rustc --version) - The example runs fine on rustc 1.58.1 (db9d1b20b 2022-01-20), I can't guarantee anything for the nightly build, I would also strongly recommend to not play around in nightly unless you really need a feature - trying nightly has many pitfalls.

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

I've seen and fixed it, so that wasn't the problem. Added some imports and the one ), but the problem is still there.

Did you commit that change? I can't debug your executor.

@mawoka-myblock
Copy link
Author

Did you commit that change? I can't debug your executor.

Nope...

Also my example still runs fine. What compiler version are you on? (running rustc --version) - The example runs fine on rustc 1.58.1 (db9d1b20b 2022-01-20), I can't guarantee anything for the nightly build, I would also strongly recommend to not play around in nightly unless you really need a feature - trying nightly has many pitfalls.

For me, rust version 1.59.0 has the same problem (which is stable)

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

What target are you compiling for? (please run rustc --print cfg for information)

@mawoka-myblock
Copy link
Author

What target are you compiling for? (please run rustc --print cfg for information)

debug_assertions
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_os="linux"
target_pointer_width="64"
target_vendor="unknown"
unix

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

For me (aarch64-apple-darwin) the example works on 1.59.

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

What target are you compiling for? (please run rustc --print cfg for information)

debug_assertions
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_os="linux"
target_pointer_width="64"
target_vendor="unknown"
unix

this sounds alright.... weird that the example throws the error for you...

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Ah the input bot doesn't compile for me as it's not available for MacOS.

@mawoka-myblock
Copy link
Author

Ah the input bot doesn't compile for me as it's not available for MacOS.

Good to know! Can you run the linux-binary on your mac (Intel)?
sd-replacement.zip

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Ah the input bot doesn't compile for me as it's not available for MacOS.

Good to know! Can you run the linux-binary on your mac (Intel)? sd-replacement.zip

Apparently not... I am sorry that I can't help you here. What error do you see when you execute my example client? Does anything after connect() work? Or does the client panic as soon as connect is invoked?

@mawoka-myblock
Copy link
Author

Ah the input bot doesn't compile for me as it's not available for MacOS.

Good to know! Can you run the linux-binary on your mac (Intel)? sd-replacement.zip

Apparently not... I am sorry that I can't help you here. What error do you see when you execute my example client? Does anything after connect() work? Or does the client panic as soon as connect is invoked?

At first, I increased the sleep to 10s, because the error occurs only after ~8 seconds. Then, It just connects to the server and does nothing (with is fine since it's waiting). Then it suddenly panics without a stacktrace sometimes.

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 19, 2022

I've also tried the same thing on another linux machine seconds ago and it's completely the same error (Nightly compiler). Stable compiler is the same.

@mawoka-myblock
Copy link
Author

What now?

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

I added some debug logging on a different branch, could you please add the dependency as like:
rust_socketio = { git = "https://github.com/1c3t3a/rust-socketio", branch = "issue-166"} and copy the error message.

@mawoka-myblock
Copy link
Author

thread '<unnamed>' panicked at 'EngineIO Error: Invalid packet id: 234', /home/mawoka/.cargo/git/checkouts/rust-socketio-ef22eed71d095901/0fbb5e5/socketio/src/client/builder.rs:279:21

That's the new error!

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Oke, this error originates from an invalid packet send by the server... that's weird...

@mawoka-myblock
Copy link
Author

Let me quickly write a nodejs socket-server!

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 19, 2022

The node-server doesn't seem to have the problem.

const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', (socket) => {
  socket.on("server_connect", (data) => {
    console.log(data);
    socket.join("1");
  })
  socket.on("execute", (data) => {
    console.log(data);
    socket.to("1").emit("execute", data);
  })
});

server.listen(8000, () => {
  console.log('listening on *:8000');
});

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Mh... weird... I am currently trying the example in an Ubuntu VM

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Oke the example worked on the following (virtual) machine:

debug_assertions
target_arch="aarch64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_os="linux"
target_pointer_width="64"
target_vendor="unknown"
unix

I really don't have any idea where that error comes from and why it only appears on your machine...

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Could you trace the messages via Wireshark? That might help to find the malicious packet...

@mawoka-myblock
Copy link
Author

Could you trace the messages via Wireshark? That might help to find the malicious packet...

I will try :D

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Did you also run the same server as I did for my example?

@mawoka-myblock
Copy link
Author

Nope. I've used the following one, but the error also occurred with your server.

import json

import socketio
from server.config import settings
from hashlib import sha256

sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=["*", "https://amritb.github.io"])


def get_room_name(phrase: str) -> str:
    return sha256(f"{phrase}-{settings.secret_key}".encode()).hexdigest()


@sio.on('*')
async def catch_all(event, sid, data):
   print(f"{sid} {event} {data}")


@sio.event
async def server_connect(sid: str, data: dict[str, str] | str):
    if type(data) is str:
        data = json.loads(data)
    print(sid, )
    phrase = data["phrase"]
    word_list = phrase.split(" ")
    print(f"{sid} connected with {phrase} and {word_list}")
    if len(word_list) != 5:
        print("wrong number of words")
        await sio.emit("on_error", {"message": "wrong phrase"}, room=sid)
        return
    async with sio.session(sid) as session:
        session["phrase"] = phrase
    sio.enter_room(sid, get_room_name(phrase))


@sio.event
async def execute(sid, data):
    phrase = (await sio.get_session(sid))["phrase"]
    print(data, "Execute!")
    await sio.emit("execute", data, room=get_room_name(phrase))

@mawoka-myblock
Copy link
Author

Could you trace the messages via Wireshark? That might help to find the malicious packet...

Sent it via mail!

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Nope. I've used the following one, but the error also occurred with your server.

import json

import socketio
from server.config import settings
from hashlib import sha256

sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=["*", "https://amritb.github.io"])


def get_room_name(phrase: str) -> str:
    return sha256(f"{phrase}-{settings.secret_key}".encode()).hexdigest()


@sio.on('*')
async def catch_all(event, sid, data):
   print(f"{sid} {event} {data}")


@sio.event
async def server_connect(sid: str, data: dict[str, str] | str):
    if type(data) is str:
        data = json.loads(data)
    print(sid, )
    phrase = data["phrase"]
    word_list = phrase.split(" ")
    print(f"{sid} connected with {phrase} and {word_list}")
    if len(word_list) != 5:
        print("wrong number of words")
        await sio.emit("on_error", {"message": "wrong phrase"}, room=sid)
        return
    async with sio.session(sid) as session:
        session["phrase"] = phrase
    sio.enter_room(sid, get_room_name(phrase))


@sio.event
async def execute(sid, data):
    phrase = (await sio.get_session(sid))["phrase"]
    print(data, "Execute!")
    await sio.emit("execute", data, room=get_room_name(phrase))

I am no python expert, how do you start the server in this example?

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 19, 2022

I am no python expert, how do you start the server in this example?

Sorry, I've mounted it in a different file, the following should be "startable" with uvicorn [file]:app:

import json

import socketio
from server.config import settings
from hashlib import sha256
from fastapi import FastAPI
from socketio import ASGIApp

sio = socketio.AsyncServer(async_mode="asgi", cors_allowed_origins=["*", "https://amritb.github.io"])


def get_room_name(phrase: str) -> str:
    return sha256(f"{phrase}-{settings.secret_key}".encode()).hexdigest()


@sio.on('*')
async def catch_all(event, sid, data):
    print(f"{sid} {event} {data}")


@sio.event
async def server_connect(sid: str, data: dict[str, str] | str):
    if type(data) is str:
        data = json.loads(data)
    print(sid, )
    phrase = data["phrase"]
    word_list = phrase.split(" ")
    print(f"{sid} connected with {phrase} and {word_list}")
    if len(word_list) != 5:
        print("wrong number of words")
        await sio.emit("on_error", {"message": "wrong phrase"}, room=sid)
        return
    async with sio.session(sid) as session:
        session["phrase"] = phrase
    sio.enter_room(sid, get_room_name(phrase))


@sio.event
async def execute(sid, data):
    phrase = (await sio.get_session(sid))["phrase"]
    print(data, "Execute!")
    await sio.emit("execute", data, room=get_room_name(phrase))


app = FastAPI()
app.mount("/", ASGIApp(sio))

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 19, 2022

Hey @mawoka-myblock, can you confirm that the error is gone with version 0.3.1? ;)

@mawoka-myblock
Copy link
Author

mawoka-myblock commented Mar 19, 2022

I am so sorry to tell you, that it didn't fix my bug, although the panic comes even later (probably because of the node server)...
My Socket.IO-server si deployed (https://sd-replacement-server.mawoka.eu/socket.io/), so you can test it, if you need to.

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 21, 2022

No way really? I am going to take a look again. Anyhow I fixed another bug, that's for sure :D

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 21, 2022

Oke are you sure you've set the right version in your Cargo.toml (0.3.1)? I don't get an error when being connected...

@mawoka-myblock
Copy link
Author

Oke are you sure you've set the right version in your Cargo.toml (0.3.1)? I don't get an error when being connected...

Yes, but the panic occurs after half an hour or even later!

@mawoka-myblock
Copy link
Author

I've just noticed: The issue that occurs only after half an hour, could also be render shutting down. I'll keep you up-to-date

@1c3t3a
Copy link
Owner

1c3t3a commented Mar 22, 2022

Any news? This implementation generally doesn't automatically reconnect on errors (like e.g. the JS implementation) instead it throws an error. This might happen if the underlying transport unexpectedly resets connection.

@mawoka-myblock
Copy link
Author

Any news? This implementation generally doesn't automatically reconnect on errors (like e.g. the JS implementation) instead it throws an error. This might happen if the underlying transport unexpectedly resets connection.

The error is exactly the same
thread '<unnamed>' panicked at 'EngineIO Error', /home/mawoka/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_socketio-0.3.1/src/client/builder.rs:229:21
stack backtrace:
   0:     0x56128828307c - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x56128828307c - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x56128828307c - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x56128828307c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x5612882aafec - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x56128827c203 - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x561288285792 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x561288285792 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x561288285792 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x561288285375 - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x561288285de3 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:606:17
  11:     0x561288285b00 - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
  12:     0x561288283524 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
  13:     0x561288285839 - rust_begin_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
  14:     0x561287832b11 - core::panicking::panic_fmt::h3a79a6a99affe1d5
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
  15:     0x561287a641da - core::panicking::panic_display::h8b37cb28aa94a8cc
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:72:5
  16:     0x561287a64647 - rust_socketio::client::builder::ClientBuilder::connect::{{closure}}::hf384cc7c95ce5f63
                               at /home/mawoka/.cargo/registry/src/github.com-1ecc6299db9ec823/rust_socketio-0.3.1/src/client/builder.rs:229:21
  17:     0x561287a70db0 - std::sys_common::backtrace::__rust_begin_short_backtrace::h87684fdca6cc0b91
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:123:18
  18:     0x561287a5ef0d - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::ha8c0ce859bdc3e7a
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/thread/mod.rs:477:17
  19:     0x561287a5f571 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h8eed1059e7960796
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panic/unwind_safe.rs:271:9
  20:     0x561287a70f89 - std::panicking::try::do_call::h649f73858970f47d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40
  21:     0x561287a711bb - __rust_try
  22:     0x561287a70ec1 - std::panicking::try::hebe742b36b7d71db
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19
  23:     0x561287a5f531 - std::panic::catch_unwind::h14593c1194527bd8
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14
  24:     0x561287a5ed29 - std::thread::Builder::spawn_unchecked::{{closure}}::h322906b2982d0729
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/thread/mod.rs:476:30
  25:     0x561287a61fbf - core::ops::function::FnOnce::call_once{{vtable.shim}}::h02e5ee1473c29751
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
  26:     0x56128828b8e3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49b6c7c5155a2296
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9
  27:     0x56128828b8e3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha8b5234bfeb15105
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9
  28:     0x56128828b8e3 - std::sys::unix::thread::Thread::new::thread_start::h6f207dd842d64859
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys/unix/thread.rs:108:17
  29:     0x7f3a52b945c2 - start_thread
  30:     0x7f3a52c19584 - __clone
  31:                0x0 - <unknown>

I don't know if the connection gets interrupted, but why should it get interrupted?

@milandekruijf
Copy link

Any update on this issue? I have the same thing happening to me.

@mawoka-myblock
Copy link
Author

Yea, this issue has never been solved...

@milandekruijf
Copy link

Wrapping the socket inside a tokio::task::spawn_blocking did it for me. Some things must've been changed though, because I didn't get an error from tokio before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants