mogui / mdwamp Goto Github PK
View Code? Open in Web Editor NEWMDWamp is a client side objective-C implementation of the WebSocket subprotocol WAMP.
License: Apache License 2.0
MDWamp is a client side objective-C implementation of the WebSocket subprotocol WAMP.
License: Apache License 2.0
Whenever I register an RPC I get an success callback for registration and error if i try to re-register the RPC but I am not getting a callbacks from the server for invocations made from the server for that URI
Hello,
I admire your work. It is really awesome what you are doing. But, i was wondering if you can provide some examples. I know your usage examples are well enough for someone, but a complete example to show how something done would be really awesome.
Thank you.
Should add to the build instructions that SocketRocket has framework dependencies as well:
Framework Dependencies
Your .app must be linked against the following frameworks/dylibs
libicucore.dylib
CFNetwork.framework
Security.framework
Foundation.framework
CocoaHTTPServer has a websockets implementation. Since you are familiar with the GCDWebServer, it would be swell if you could add this functionality to the GCDWebServer.
The title here basically says it all.
Hi Mogui!
I am working with publish/subcribe protocol with Wamp.
I dont know why when i unsubcibe a event, MDWamp returns response "mdwamp.error.no_such_subscription".
Then I debuged and found where the isssue happen. Look at this: line 543, DMWamp.m
if (!self.subscriptionID[topic] && !self.subscriptionEvents[topic]) {
// inexistent sunscription we abort
MDWampError *error = [[MDWampError alloc] initWithPayload:@[@-12, @0, @{}, @"mdwamp.error.no_such_subscription"]];
result([error makeError]);
return;
}
self.subscriptionEvents is key is nsnumber, key not is topic (my string).
To More clear, please check my attactment debug screen shot.
Thanks!
Sometimes socket connection is established but actually calls doesn't works.
Can I perform some kind of ping every small amount of time to reconnect if such situation happens?
MDWampTransportWebSocket *transport = [[MDWampTransportWebSocket alloc] initWithServer:[NSURL URLWithString:@"ws://localhost:8080/ws"] protocolVersions:@[kMDWampProtocolWamp2msgpack, kMDWampProtocolWamp2json]];
MDWamp *ws = [[MDWamp alloc] initWithTransport:transport realm:@"realm1" delegate:self];
[AppDel setWampConnection:ws];
[ws connect];
NSLog(@"%d",[ws isConnected]);
if ([ws isConnected]){
[ws publishTo:@"com.topic.hello" args:nil kw:@{@"user":@[@"foo", @"bar"]} options:@{@"acknowledge":@YES, @"exclude_me":@NO} result:^(NSError *error) {
// if acknowledge is TRUE this callback will be called to notify the successful publishing
NSLog(@"published? %@", (error==nil)?@"YES":@"NO");
}];
}
All the libraries have been added correctly and program runs , I call crossbar start on my project and it logs
2015-11-20T11:42:20-0800 [Controller 23820] Entering reactor event loop...
2015-11-20T11:42:20-0800 [Controller 23820] Warning, could not set process title (setproctitle not >installed)
2015-11-20T11:42:20-0800 [Controller 23820] Process utilities not available
2015-11-20T11:42:20-0800 [Controller 23820] Joined realm 'crossbar' on node management router
2015-11-20T11:42:20-0800 [Controller 23820] No WAMPlets detected in enviroment.
2015-11-20T11:42:20-0800 [Controller 23820] Starting Router with ID 'worker1'...
2015-11-20T11:42:20-0800 [Router 23821] Worker running under CPython-KQueueReactor
2015-11-20T11:42:20-0800 [Router 23821] Process utilities not available
2015-11-20T11:42:20-0800 [Controller 23820] Router with ID 'worker1' and PID 23821 started
2015-11-20T11:42:20-0800 [Controller 23820] Router 'worker1': realm 'realm1' (named 'realm1') started
2015-11-20T11:42:20-0800 [Controller 23820] Router 'worker1': role 'role1' (named 'anonymous') >started on realm 'realm1'
2015-11-20T11:42:20-0800 [Router 23821] Site starting on 8080
2015-11-20T11:42:20-0800 [Controller 23820] Router 'worker1': transport 'transport1' started
any ideas on the problem?
Since I added MDWamp, I get these kinds of errors. In the hundreds.
But only after the app ran for about an hour.
No clue what this means. Can somebody help me?
<Error>: tcp_connection_host_start 7181 DNSServiceGetAddrInfo failed: -65537
<Warning>: dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)
<Error>: tcp_connection_host_start 7182 DNSServiceGetAddrInfo failed: -65537
<Warning>: dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)
<Error>: tcp_connection_host_start 7182 DNSServiceGetAddrInfo failed: -65537
<Warning>: dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)
<Error>: tcp_connection_host_start 7183 DNSServiceGetAddrInfo failed: -65537
<Warning>: dnssd_clientstub deliver_request: socketpair failed 24 (Too many open files)
<Error>: tcp_connection_host_start 7183 DNSServiceGetAddrInfo failed: -65537
[MDWamp transportDidFailWithError:] DID FAIL reason received bad response code from server 426
some("received bad response code from server 426")
I try to use library in my Swift app and sometimes I receive errors resulting in closing connection. The problem is in generator of random numbers in MDWamp.m function: - (NSNumber *) generateID
which generates negative numbers (not always). There should be something wrong with them under Swift compiler or something.
Session closed: [NSLocalizedDescription: WAMP Protocol Error ('request' in CALL: invalid value -312046319 for ID)] code: 1002reason: WAMP Protocol Error ('request' in CALL: invalid value -312046319 for ID)
I have realized that [NSNumber numberWithInt:r] does its work wrong.
Solution is to change the above to:
[NSNumber numberWithUnsignedInt:r];
With the recent release of iOS 7.1 and Xcode 5.1, it seems like I am unable to build a new framework with the proper header files for use. The older MDWamp framework that we were using was coming up with a linker error:
ld: warning: ignoring file ../Banter/MDWamp.framework/MDWamp, missing required architecture x86_64 in file ../Banter/MDWamp.framework/MDWamp (3 slices)
Undefined symbols for architecture x86_64:
"OBJC_CLASS$_MDWamp", referenced from:
objc-class-ref in BINetworkManager.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestion in to how to resolve this issue, would be appreciated!
Can you create a branch for 1.x support so we can pull request some bugfix for those using Wampv1 ?
Thanks
Can you please help me to determine why I get an assertion error while using Thruway WAMP router with MDWamp client library on disconnect. I even do not understand is this issue related to MDWamp library or Thruway router library. Thats why I created the ticket here and I created the ticket in Thruway router repo too. It is also possible that the issue I have experiencing is related with incorrect low level protocol implementation in server-side/client websocket library that Thruway/MDWamp (Ratchet/SocketRocket) uses, but I have no appropriate skills to determine what is wrong in this case.
For explain the issue in simple way I just created the simple iOS app that you can run and start to debug. Here is the repo that contains iOS workspace sources, the latest thruway router sources. It also contain crossbar router config.json with same simple router configuration.
When I use thruway router and I call mdwap.disconnect() I got assertion fail error:
Assertion failed: (mapped_size >= sizeof(_currentReadMaskOffset) + offset), function __33-[SRWebSocket _readFrameContinue]_block_invoke_2, file /Test MDWamp with Thruway Router/Pods/SocketRocket/SocketRocket/SRWebSocket.m, line 1128.
When I use crossbar router there is no such issue.
However I tried to use both Thruway and Crossbar routers in my web app using 'angular-wamp' library on client side and there are no any issues on disconnect while using either Thruway or Crossbar router.
Thank you.
Hi,
in this line it is checked whether or not a custom WampCRASigningBlock is provided.
However all that is passed as a parameter is the "challenge" extra of the MDWampChallenge.
When in fact I need the other ones, too: "salt", "iterations" and "keylen".
Could you pass the whole MDWampChallenge instead?
Kind regards,
Matthias
How do I use this in swift
@Property (nonatomic, strong) void (^deferredWampCRASigningBlock)( NSString *challange, void(^finishBLock)(NSString *signature) );
-[MDWamp transportDidCloseWithError:] DID CLOSE reason Stream end encountered
-[MDWampTransportWebSocket webSocketDidOpen:] negotiated protocol is wamp.2.json
-[MDWamp transportDidOpenWithSerialization:] websocket connection opened
-[MDWamp sendMessage:] Sending <MDWampHello: 0x618000223c20>
Assertion failure in -[SRWebSocket send:],
/Pods/SocketRocket/SocketRocket/SRWebSocket.m
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid State: Cannot call send: until connection is open'
There is a way to hide or not print MDWamp logs please ?
I downloaded the pre-compiled framework from the link in the readme and added it to my project. However, I get the message:
'MDWampMessage.h' file not found
Looking through the file, I can't find that header either. Did I do something wrong or does the pre-compiled link need to be updated?
Thank you!
Adam
I integrate MDWamp Library in my Project as example but it does not establish connection and return this error
-[MDWampTransportWebSocket webSocketDidOpen:] negotiated protocol is (null)
2016-02-29 09:14:46.761 WampSocket[1119:129476] *** Terminating app due to uncaught exception 'it.mogui.mdwamp', reason: 'Wrong message recived'
In generateID method:
- (NSNumber *) generateID
{
unsigned int r = arc4random_uniform(exp2(32)-1);
return [NSNumber numberWithInt:r];
}
unsigned int casting to int. In some cases result is negative ID number!
Could you please implement an opportunity to set Cookies for SRWebSocket? Like through MDWampTransportWebSocket or something.
I have an problem with MDWampClient with auth methods kMDWampAuthMethodCRA:
MDWampTransportWebSocket *transport = [[MDWampTransportWebSocket alloc] initWithServer:[NSURL URLWithString:@"ws://gateway.api.monitor.cl:9000"] protocolVersions:@[kMDWampProtocolWamp2json]];
_wamp = [[MDWamp alloc] initWithTransport:transport realm:@"cl.monitor" delegate:self];
MDWampClientConfig *conf = [[MDWampClientConfig alloc] init];
conf.authmethods = @[kMDWampAuthMethodCRA];
conf.authid = @"monitor.frontend";
conf.sharedSecret = @"monitor.97";
[_wamp setConfig:conf];
[_wamp connect];
When i call it, the "(void) mdwamp: closedSession: reason: details:" is fired:
2015-07-24 19:02:36.337 WebSockeTest[56163:3712243] -[MDWampTransportWebSocket webSocketDidOpen:] negotiated protocol is wamp.2.json
2015-07-24 19:02:36.340 WebSockeTest[56163:3712243] -[MDWamp transportDidOpenWithSerialization:] websocket connection opened
2015-07-24 19:02:36.340 WebSockeTest[56163:3712243] -[MDWamp sendMessage:] Sending <MDWampHello: 0x7f8b71487990>
2015-07-24 19:02:36.510 WebSockeTest[56163:3712243] #### Closed Code: 0 --- reason:wamp.error.not_authorized ---- details:{
message = "authentication using method 'anonymous' denied by configuration";
}
2015-07-24 19:02:36.693 WebSockeTest[56163:3712243] -[MDWamp transportDidCloseWithError:] DID CLOSE reason The operation couldn’t be completed. Connection reset by peer
It's strange because i not used anonymous method.
Many thanks!
The current version doesnt support connect server with authentication.
The server I'm trying to talk to with MDWamp uses https://github.com/ratchetphp/Ratchet which only supports WAMP v1.
Is MDWamp only compatible with v2 of WAMP? Is there any chance it can be made v1 compatible?
Hey, great work here. Do you have any plans for WAMP 2 specs??
I get EXC_BAD_ACCESS on line 492 in SRWebSocket.m
[self _performDelegateBlock:^{
if ([self.delegate respondsToSelector:@selector(webSocketDidOpen:)]) { // HERE
[self.delegate webSocketDidOpen:self];
};
}];
The property should be weak, right?
@Property (nonatomic, assign) id delegate; // SRWebSocket.h
Hi,
I am trying to install this via Pods on a swift project and include using a bridging header unfortunately I get the following error:
GCDAsyncSocket.h file not found
Any ideas about fixing this?
I am forced to use Carthage instead of CocoaPods.
While it was rather easy to integrate using CocoaPods, I just can't figure out how to build a usable framework with Carthage, or (for that matter) just using the project of this github repository.
If I clone this repository, what build artifact/product of this project am I using to integrate in another iOS app? If I use the target 'MDWamp' it complains that it's not build for the right architecture (which makes sense I guess since that is actually an OSX target. If I try to add 'libMDWamp', I just get a 'no such module' error while building.
I'm still fairly new to this whole build management topic on iOS, so maybe I'm just making a rookie mistake. If so: Could somebody give me some clue or hint on what topics exactly I should read up on.
Otherwise: Would it be possible to add a target to this project that is easily integrateable into other iOS projects?
In MDWampTransportWebSocket, setRequestCookies sets the cookies directly onto the socket, which is nil unless open has been called as part of connection. Unfortunately, this prevents the cookies from being in place before connecting to the wamp router, which is when you would need them. Suggestion would be to set cookies into a local var of MDWampTransportWebSocket and then add the cookies to the socket in the open method.
Hello!
I think MDWamp (2.2.0) has a problem with Caller Identification in call:args:kwArgs:options:complete: method.
MDWamp.m in lines 751-753 contains code:
if(opts[MDWampOption_exclude_me] == nil && self.config.caller_identification){
opts[MDWampOption_exclude_me] = @YES;
}
But I think correct lines is:
if(opts[MDWampOption_disclose_me] == nil && self.config.caller_identification){
opts[MDWampOption_disclose_me] = @YES;
}
Thank you.
in the Installation section it should 'pod "MDWamp"' with capital 'W'
Use MPMessagePack (https://github.com/gabriel/MPMessagePack) instead of MessagePack. It supports differentiation between strings and binary data, which is required by the WAMP v2 spec:
"The version 5 of MsgPack MUST BE used, since this version is able to differentiate between strings and binary values."
https://github.com/tavendo/WAMP/blob/master/spec/basic.md#serializations
Hi Mogui!
I appreciated what you have done.
Sometime I have been closed socket, I dont know why.
After debuging, I found return code is 1000, reason nil. Do you know about this?
Thanks!
https://github.com/mogui/MDWamp/blob/master/MDWamp/src/MDWampClientConfig.m#L65
Typo error, it should be authmethods rather than authmetods. Due to which Autnetication is not working
I am using the MDWamp for swift using cocopods. I initalize and connect it to server using wampcra and connect it using self.wamp?.connect() and things work fine
But If i try to disconnect and reconnect the it throws the following error
*** Assertion failure in -[SRWebSocket open], …. Pods/SocketRocket/SocketRocket/SRWebSocket.m:389
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Cannot call -(void)open on SRWebSocket more than once'
I can disconnect without any problem but problem occurs when I reconnect it
I am able to connect but I am unable to receive an events from my subscription. I also lose connection after exactly 1 minute which seems fishy, like i never really connected at all and 1 minute is the limit for not detecting a connection.
here is the printed info from when I make the initial connection. i am using swift 4.1 with ios 10
info Optional([AnyHashable("roles"): {
broker = {
features = {
"publisher_exclusion" = 1;
"subscriber_blackwhite_listing" = 1;
"subscriber_metaevents" = 1;
};
};
callee = {
"call_canceling" = 1;
"progressive_call_results" = 1;
};
caller = {
"call_canceling" = 1;
"callee_blackwhite_listing" = 1;
"caller_exclusion" = 1;
"caller_identification" = 1;
"progressive_call_results" = 1;
};
dealer = {
features = {
"caller_identification" = 1;
"progressive_call_results" = 1;
};
};
publisher = {
"publisher_exclusion" = 1;
"publisher_identification" = 1;
"subscriber_blackwhite_listing" = 1;
};
subscriber = {
"pattern_based_subscription" = 1;
"publication_trustlevels" = 1;
};
}, AnyHashable("authmethods"): <__NSArray0 0x6080000013e0>(
)
, AnyHashable("transport"): {
cookies = (
);
headers = {
Connection = (
Upgrade
);
Host = (
"sockets_server:5555"
);
Origin = (
"https://..com"
);
"Sec-WebSocket-Key" = (
"*******"
);
"Sec-WebSocket-Protocol" = (
"wamp.2.json"
);
"Sec-WebSocket-Version" = (
13
);
Upgrade = (
websocket
);
};
"query_params" = (
);
"transport_address" = "...";
type = ratchet;
url = "/server";
}])
After 1 minute my disconnect message is this
What is the status of the project? Mature? Active? Would it be possible to put it in the README.md?
Thanks - Brendon
Right now, if the delegate of a MDWamp
object is deallocated, the delegate
property becomes a dangling pointer and will crash next time a delegate method is called.
I'm pretty certain it can just made a weak
property and get the desired behavior of being set to nil
when the delegate deinits.
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.