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

[BUG] IDs can be larger than 2^53 #9

Open
schlefix opened this issue Dec 9, 2023 · 0 comments
Open

[BUG] IDs can be larger than 2^53 #9

schlefix opened this issue Dec 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@schlefix
Copy link

schlefix commented Dec 9, 2023

Describe the bug
Received errors like invalid value 66856894559470078 for ID or received yield for call that was not send while playing with your great crate ;) Digged a little bit in and found that you're using rng.gen_range(0..1u64.rotate_left(56) - 1) wich is lager than the definition for IDs from https://wamp-proto.org/wamp_latest_ietf.html#name-ids ( 1 to 2^53 inclusive )

changing it to rng.gen_range(1..1u64.rotate_left(53)) solved all errors with all different WAMP implementations i've tested (python, js, ts, ... ) ;)

To Reproduce
created a simple router in rust:

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
    info!("start");
  
    tokio::spawn(async move {
        let mut router = Router::new();
        router.add_realm("ca.test");
        
        router.listen("127.0.0.1:12345").join();
       
        println!("router ende");
    });
    println!("Press enter to quit");
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    Ok(())
}

tested with a simple python script (registering a function and calling it)


#from autobahn.twisted.wamp import ApplicationSession
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
import asyncio
class MyComponent(ApplicationSession):


    async def onJoin(self, details):
        print(details)
        # 3. register a procedure for remote calling
        def add2(x, y):
            return x + y

        await self.register(add2, 'ca.test.add2')

        # 4. call a remote procedure
       
        while True:
            res = await self.call('ca.test.add2', 2, 3)
            print("Got result: {}".format(res))
            await asyncio.sleep(1)
        #self.leave()

    def onDisconnect(self):
        asyncio.get_event_loop().stop()

if __name__ == "__main__":
    print("starte")
    runner = ApplicationRunner("ws://127.0.0.1:12345","ca.test")
    runner.run(MyComponent)

resulted in (Python)

    raise ProtocolError("{0}: invalid value {1} for ID".format(message, value))
autobahn.wamp.exception.ProtocolError: 'registration' in REGISTERED: invalid value 66856894559470078 for ID

Version Information
pulled 0.2.1 from cargo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant