wampire
wampire copied to clipboard
[BUG] IDs can be larger than 2^53
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