ohyo-io / wampire Goto Github PK
View Code? Open in Web Editor NEWAsynchronous Rust implementation of a WAMP (Web Application Messaging Protocol) client and router
License: MIT License
Asynchronous Rust implementation of a WAMP (Web Application Messaging Protocol) client and router
License: MIT License
Running endpoint example and api_user example, the addition example is not able to parse it's arguments correctly.
Enter a command (or type "help")
add 10,10
Error: CallError { reason: InvalidArgument, args: Some([String("Expected integer, got 10")]), kwargs: None }
net2
crate has been deprecated; usesocket2
instead
Details | |
---|---|
Status | unmaintained |
Package | net2 |
Version | 0.2.37 |
URL | deprecrated/net2-rs@3350e38 |
Date | 2020-05-01 |
The net2
crate has been deprecated
and users are encouraged to considered socket2
instead.
See advisory page for additional details.
pub fn call(
&mut self,
procedure: URI,
args: Option<List>,
kwargs: Option<Dict>,
) -> Pin<Box<dyn Future<Output = Result<(List, Dict), CallError>>>> {
info!("Calling {:?} with {:?} | {:?}", procedure, args, kwargs);
let request_id = self.get_next_session_id();
let (complete, receiver) = oneshot::channel();
let mut info = self.connection_info.lock().unwrap();
info.call_requests.insert(request_id, complete);
info.send_message(Message::Call(
request_id,
CallOptions::new(),
procedure,
args,
kwargs,
))
.unwrap();
Box::pin(async {
receiver.await.unwrap_or(Err(CallError {
reason: Reason::InternalError,
args: None,
kwargs: None,
}))
})
}
Why is there a blank call option in info.send_message() ?
The wiki page about authentication has only broken links, I'm unable to find an example to use wampcra.
I get:
Router aborted connection. Reason: CustomReason(URI { uri: "wamp.error.no_auth_method" })
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
Line 17 in de5aa3b
The WampResult
type which is returned by many public facing APIs wraps the private wampire::error::Error type.
This prevents callers from implementing From(wampire::error::Error)
for their custom error types.
The call to connect()
ends up calling unwrap()
which makes the program panic.
Client code :
let mut client = match connection.connect() {
Ok(c) => c,
Err(e) => {
return Err(ProjectError::ConnectionFailed(format!("{}",e)))
},
};
Log output
[2019-12-26T20:05:13Z ERROR ws::handler] WS Error <Io(Os { code: 10061, kind: ConnectionRefused, message: "No connection could be made because the target machine actively refused it." })>
[2019-12-26T20:05:13Z TRACE ws::io] WebSocket connection to token=Token(0) disconnected.
[2019-12-26T20:05:13Z TRACE ws::io] Active connections 0
[2019-12-26T20:05:13Z DEBUG ws::io] Shutting down websocket client.
[2019-12-26T20:05:13Z DEBUG ws::factory] Factory received WebSocket shutdown request.
[2019-12-26T20:05:13Z TRACE mio::poll] deregistering handle with poller
[2019-12-26T20:05:13Z TRACE mio::poll] deregistering handle with poller
[2019-12-26T20:05:13Z TRACE mio::poll] deregistering handle with poller
[2019-12-26T20:05:13Z DEBUG wampire::client] Result of connection: Ok(())
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src\libcore\result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.