matthias247 / jawampa Goto Github PK
View Code? Open in Web Editor NEWWeb Application Messaging Protocol (WAMP v2) support for Java
License: Apache License 2.0
Web Application Messaging Protocol (WAMP v2) support for Java
License: Apache License 2.0
the Observable returned by registerProcedure and makeSubscription, call Subscriber.onError if the registration/subscription fails. but there is no callback to tell that the call is successfull.
I dont know how Observable can be used for such callback. can you provide your insight on this.
Hey,
I'm working on a project and I'm testing some ideas for messaging.
The code below works, I am now trying to do the same thing with the PRC but I can not send a Chat Message, this is not impossible?
Subscription subscribed = client.makeSubscription(eventName.trim().toLowerCase(), ChatMessage.class).subscribe(new Subscriber<ChatMessage>() {
@Override
public void onNext(final ChatMessage message) {
Log.d("andre","Message say: " + message.getTextMessage());
}
@Override
public void onError(Throwable throwable) {
System.out.println("onError : " + throwable);
}
@Override
public void onCompleted() {
System.out.println("onCompleted ");
}
});
Call client.publish(mChatMessage.getUserId().trim().toLowerCase(), mChatMessage);
thks!
Hi, I wanna do some backend logic in Router while procedures being called between Clients. What I am thinking is to extend the WampRouter class so CallMessage handller could be override. However it seems impossible now without changing WampRouter class, is it?
It says here that clients who send PUBLISH messages only receive PUBLISHED (or ERROR / PUBLISH) messages back if they have included "acknowledge" : true in the Options dict. If I'm not mistaken, the jawampa broker is ignoring this flag and is always returning PUBLISHED acknowledgements no matter what.
In theory, this is probably not a breaking bug in most cases (an extra websocket message shouldn't hurt anybody), but I just thought I'd point this out as an easy change you can make if you want to more closely conform to the basic profile.
I am getting the following error when I try to publish a json msg({"test":"message"}) through crossbar.io and try to process the msg using jawampa. I also noticed that after this failure, jawampa unsubscribes to the the topic.Why is the subscription cancelled even if one message is incorrect? Please let me know if you see any issues with this code.
Observable<String> msgSubscription = wampclient.makeSubscription(topicName, String.class);
msgSubscription.subscribe(processMessageAction);
16:51:33.621 [WampClientEventLoop] DEBUG w.w.j.t.n.WampDeserializationHandler - Deserialized Wamp Message: [36,7054800803741494,1958756529312882,{},[{"test":"message"}]]
16:51:33.634 [WampClientEventLoop] ERROR ws.wamp.jawampa.WampClient - error
java.lang.IllegalArgumentException: Can not deserialize instance of java.lang.String out of START_OBJECT token
at [Source: N/A; line: -1, column: -1]
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:2774) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:2700) ~[jackson-databind-2.4.4.jar:2.4.4]
at ws.wamp.jawampa.WampClient$3.call(WampClient.java:389) [classes/:na]
at ws.wamp.jawampa.WampClient$3.call(WampClient.java:1) [classes/:na]
at rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55) [rxjava-1.0.8.jar:1.0.8]
at ws.wamp.jawampa.client.SessionEstablishedState.onMessage(SessionEstablishedState.java:365) [classes/:na]
17:02:35.867 [WampClientEventLoop] DEBUG w.w.j.t.n.WampSerializationHandler - Wamp Message: ws.wamp.jawampa.WampMessages$UnsubscribeMessage@41df3cc2
Does the library support connection through a proxy server? I want to run the library behind a proxy server to connect to a WAMP router, but it hangs on the connecting phase...Thank you in advance!
BTW: the http_proxy
environment variable is set.
Surprisingly, the README is consistent with this error.
Other than that, this library seems pretty cool so far and I'm enjoying trying it out.
Below is my client code;
final WampClient client1;
WampClientBuilder builder = new WampClientBuilder();
try {
builder.witUri("ws://192.168.1.96:8080/ws")
.withRealm("realm1")
.withInfiniteReconnects()
.withReconnectInterval(1, TimeUnit.SECONDS);
client1 = builder.build();
} catch (WampError e) {
e.printStackTrace();
return;
}
client1.statusChanged().subscribe(new Action1<WampClient.Status>() {
private Subscription procSubscription;
public void call(WampClient.Status t1) {
Log.d("info","Session status changed to " + t1);
if (t1 == WampClient.Status.Connected) {
Log.d("info","Connected");
}
}
});
client1.open();
The output is always;
Session status changed to Connecting..
Session status changed to Disconnecting..
And it goes on..
My server is;
https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/basic/rpc/slowsquare/backend.py
can you please help..
where do i start if i wanted to run jawampa on jetty-websocket?
Is there a maximum size for the arguments when publishing an event?
I use this code (java): wampClient.publish(token, response.toString());
response.toString())
is a long json-string in my case. It has about 70.000 characters. I have the suspicion that the event does not get published, because when I replace response.toString
with a short string, the event gets published as expected.
I dont know much about the internals of Wamp and an initial debugging session into the code did not provide me with much insight. As I said above, I think that the long string is causing some problems.
Any help/feedback is welcome. If you need more information, please let me know.
Does jawampa support sending binary using MessagePack ? I mean if I have picture data for example and I want to sand it using MessagePack - is it possible? I am asking it because README says "jawampa does not properly support the transmission of binary values as required in the WAMP specification" and now it is not clear all possibilities of sending binaries. Sorry
When the port number in the server URL is omitted, e.g ws://localhost/ws
, the following exception is rised:
18:53:22,974 INFO [stdout] (WampClientEventLoop) rx.exceptions.OnErrorNotImplementedException: port out of range:-1
18:53:22,975 INFO [stdout] (WampClientEventLoop) at rx.Observable$36.onError(Observable.java:8416) ~[rxjava-core-0.20.4.jar:na]
18:53:22,975 INFO [stdout] (WampClientEventLoop) at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:128) ~[rxjava-core-0.20.4.jar:na]
18:53:22,975 INFO [stdout] (WampClientEventLoop) at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:97) ~[rxjava-core-0.20.4.jar:na]
18:53:22,975 INFO [stdout] (WampClientEventLoop) at rx.internal.operators.NotificationLite.accept(NotificationLite.java:144) ~[rxjava-core-0.20.4.jar:na]
18:53:22,975 INFO [stdout] (WampClientEventLoop) at rx.subjects.SubjectSubscriptionManager$SubjectObserver.emitNext(SubjectSubscriptionManager.java:254) ~[rxjava-core-0.20.4.jar:na]
18:53:22,975 INFO [stdout] (WampClientEventLoop) at rx.subjects.BehaviorSubject.onError(BehaviorSubject.java:135) ~[rxjava-core-0.20.4.jar:na]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at ws.wamp.jawampa.WampClient.performDispose(WampClient.java:243) ~[jawampa-0.1.0.jar:na]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at ws.wamp.jawampa.WampClient.beginConnect(WampClient.java:418) ~[jawampa-0.1.0.jar:na]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at ws.wamp.jawampa.WampClient.access$000(WampClient.java:92) ~[jawampa-0.1.0.jar:na]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at ws.wamp.jawampa.WampClient$2.run(WampClient.java:271) ~[jawampa-0.1.0.jar:na]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) ~[netty-common-4.0.23.Final.jar:4.0.23.Final]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
18:53:22,976 INFO [stdout] (WampClientEventLoop) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [netty-common-4.0.23.Final.jar:4.0.23.Final]
18:53:22,977 INFO [stdout] (WampClientEventLoop) at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
18:53:22,977 INFO [stdout] (WampClientEventLoop) Caused by: java.lang.IllegalArgumentException: port out of range:-1
18:53:22,977 INFO [stdout] (WampClientEventLoop) at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143) ~[na:1.8.0_25]
18:53:22,977 INFO [stdout] (WampClientEventLoop) at java.net.InetSocketAddress.<init>(InetSocketAddress.java:224) ~[na:1.8.0_25]
18:53:22,977 INFO [stdout] (WampClientEventLoop) at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:96) ~[netty-transport-4.0.23.Final.jar:4.0.23.Final]
18:53:22,977 INFO [stdout] (WampClientEventLoop) at ws.wamp.jawampa.transport.WampClientChannelFactoryResolver$1.createChannel(WampClientChannelFactoryResolver.java:110) ~[jawampa-0.1.0.jar:na]
18:53:22,977 INFO [stdout] (WampClientEventLoop) at ws.wamp.jawampa.WampClient.beginConnect(WampClient.java:384) ~[jawampa-0.1.0.jar:na]
is there a method, which can be used by a server to destroy a client?
currently, only the client can unsubscribe/unregister from the WAMP server by itself. however, if the client crashes, the subscribe id
stays occupied by a dead client. hence, we need to change the subscribe id
manually and restart the client, which is not feasible in a productive environment.
Hi Matthias n team!
thanks for this work!
I need to use on Android, I have referenced this lib using gradle,
All seems to work...
Im following this java example:
https://github.com/Matthias247/jawampa_crossbar/blob/master/src/main/java/ws/wamp/jawampa/CrossbarExample.java
the code is importing and almost working,
but
on
WampClient.Status
I get : "Cannot resolve symbol 'Status' "
is an import missing?
please find my hello world android app [intellij] on,
https://github.com/mako34/WampDroid
this is the only bug to fix so I can have the protocol working for android, how to fix?
Thanks
I have a (non-jawampa) WAMP client that's trying to connect to my jawampa server at the root path ( "/" ) and is expecting a websocket handshake. I tried to configure my SimpleWampWebsocketListener to listen on the root path (by putting "/" as the uri) but it is still serving a 200 OK response "This server provides a wamp router on path" instead of the websocket handshake. Thus, the client returns the error message "Error during WebSocket handshake: Unexpected response code: 200"
Is there a way to toggle the behavior that sets up that handler, so that I can set up my WAMP router to listen on the root path, without this placeholder getting in the way?
Hello,
When I run the project on my local machine works okay, but when I try to deploy on an external tomcat doesn't work. I really do not know how to perform the deploy correctly.
Here is my gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-cargo-plugin:2.0.3'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'com.bmuschko.cargo'
sourceCompatibility = 1.6
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
//Required repos
mavenCentral()
maven { url "https://raw.github.com/Matthias247/jawampa/mvn-repo/"}
}
cargo {
containerId = 'tomcat7x'
port = 8080
deployable {
context = 'router'
}
remote {
hostname = 'remote_ip'
username = '******'
password = '*******'
}
}
dependencies {
compile("com.google.guava:guava:17.0")
compile ("javax.inject:javax.inject:1")
compile 'ws.wamp.jawampa:jawampa:0.1.2'
def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
I am trying to open connection to the server and now I have an issue with it. If it local started crossbar.io server - I am able to connect to it, but I am can't connect to any internet server ( for example wss://demo.crossbar.io/ws ). In this case only cycled disconnect-connection states. What I am doing incorrect ?
try {
// Create a builder and configure the client
WampClientBuilder builder = new WampClientBuilder();
// builder.withUri("ws://192.168.1.39:8282/ws")
builder.withUri("wss://demo.crossbar.io/ws")
.withRealm("realm1")
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
// Create a client through the builder. This will not immediatly start
// a connection attempt
client = builder.build();
client.statusChanged().subscribe(new Action1<WampClient.Status>() {
private Subscription procSubscription;
public void call(WampClient.Status t1) {
Log.d("info", "Session status changed to " + t1);
if (t1 == WampClient.Status.Connected) {
Log.d("info", "Connected");
}
}
});
client.open();
} catch (WampError e) {
// Catch exceptions that will be thrown in case of invalid configuration
e.printStackTrace();
return;
}
Hello,
I'm working on a project where we use gradle to manage dependencies, which the possibility of obtaining jawampa via gradle?
thank you!
I trying to understand where I have to set the type of data - msgpack or json and do not found how I can change it. Is it available or not ?
Hi,
Thank you very much for your project. It is very helpful to my work. I have a problem. Could you please help me?
Router: I open a jawampa websocket router.
Client:
case 1: I open a jawampa websocket client. Pub/Sub, Call Procedure work perfectly.
case 2: I create a HTML page with Javascipt code to open a websocket client.
- 2a. Pub/Sub, Call Procedure work perfectly with Chrome and Opera
- 2b. Firefox has problem. It cannot open a connection (So Pub/Sub, Call Procedure of course do not work)
QUESTION: Why if I open the HTML page in Firefox, it cannot open a connection?
ANSWER:
In browser debug mode, I see that Chrome & Opera send "ws://uri" request
GET ws://localhost:8980/websocketdemo HTTP/1.1
Host: localhost:8980
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
Origin: null
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Sec-WebSocket-Key: FvZnlLuQeKMH+k8XMiDQMg==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Protocol: wamp.2.json
Meanwhile, Firefox sends "http://uri" request. As a consequence, in the server, we go to the method ws.wamp.jawampa.transport.SimpleWampWebsocketListener.WebSocketServerHandler.handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) (In the SimpleWampWebsocketListener.java file) to process this http request. Therefore, there is no handshake and no connection.
I can fix the problem by tricky work. In the method handleHttpRequest above, I call method tryWebsocketHandshake (of course, I change tryWebsocketHandshake from private to public) from the WampServerWebsocketHandler object that you add to the pipeline (pipeline.addLast(new WampServerWebsocketHandler(uri.getPath(), router))). But this is tricky and not good. By the way, I do not really understand websocket, just know how to use it.
SO, COULD YOU PLEASE UPGRADE YOUR CODE so that it can also work with Firefox???
Hi,
it's indicated in the documentation that a client must be closed. However, trying to close the client results in an exception if the connection attempt fails.
Here is a minimal example:
package ws.wamp.example;
import rx.schedulers.*;
import ws.wamp.jawampa.*;
import java.util.concurrent.TimeUnit;
class Main {
public static void main(String[] args) {
final WampClient client;
try {
WampClientBuilder builder = new WampClientBuilder();
builder.witUri("ws://localhost:8080/ws")
.withRealm("foobar");
client = builder.build();
client.statusChanged()
.subscribe(s -> {}, e -> {e.printStackTrace();});
client.open();
Thread.sleep(5000);
System.out.println("Trying to close the client.");
client.close();
System.out.println("Client closed.");
} catch (Exception e) {
e.printStackTrace();
return;
}
}
}
and it fails like this
ApplicationError(wamp.error.no_such_realm, [], {})
at ws.wamp.jawampa.WampClient.onMessageReceived(WampClient.java:549)
at ws.wamp.jawampa.WampClient.access$400(WampClient.java:92)
at ws.wamp.jawampa.WampClient$SessionHandler.channelRead0(WampClient.java:365)
at ws.wamp.jawampa.WampClient$SessionHandler.channelRead0(WampClient.java:314)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at ws.wamp.jawampa.transport.WampClientWebsocketHandler.channelRead(WampClientWebsocketHandler.java:63)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:161)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)
Trying to close the client.
java.util.concurrent.RejectedExecutionException: event executor terminated
at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:745)
at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:322)
at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:728)
at io.netty.util.concurrent.AbstractEventExecutorGroup.execute(AbstractEventExecutorGroup.java:114)
at ws.wamp.jawampa.WampClient.close(WampClient.java:460)
at ws.wamp.example.Main.main(Main.java:20)
Hi there,
I have a simple client that connects to the Polonix push API. It used to work for quite some time but suddenly stopped working not being able to connect.
It will sit in the Connecting state forever.
I am trying to debug it and looks like there the channel is closed in NettyWampClientConnectorProvider. It is not clear why the channel gets closed.
Can you guys give some ideas how to approach the problem. I tried all the few WAMP libraries out there and JAWAMPA was the only one that worked until recently.
This is an example code that fails. I have a JS code using Authobahn|JS which connects with no problem.
import rx.functions.Action1;
import ws.wamp.jawampa.WampClient;
import ws.wamp.jawampa.WampClientBuilder;
import ws.wamp.jawampa.transport.netty.NettyWampClientConnectorProvider;
import ws.wamp.jawampa.transport.netty.NettyWampConnectionConfig;
import java.util.concurrent.TimeUnit;
public class JawampaTest {
public static void main(String[] args) throws Exception {
NettyWampClientConnectorProvider connectorProvider = new NettyWampClientConnectorProvider();
NettyWampConnectionConfig connectionConfiguration = new NettyWampConnectionConfig.Builder().build();
WampClientBuilder builder = new WampClientBuilder();
WampClient client = builder
.withConnectorProvider(connectorProvider)
.withConnectionConfiguration(connectionConfiguration)
.withUri("wss://api.poloniex.com")
.withRealm("realm1")
.withInfiniteReconnects()
.withReconnectInterval(1, TimeUnit.SECONDS)
.build();
client.statusChanged().subscribe(new Action1<WampClient.State>() {
@Override
public void call(WampClient.State t1) {
System.out.println("Session status changed to " + t1);
}
});
client.open();
Thread.sleep(100000);
}
}
I am trying to implement dynamic authorization with crossbar.io and jawampa as a guest worker. But I cannot find anything on what I will get as parameters.
from docs http://crossbar.io/docs/Authorization/
@wamp.register('com.example.authorize')
def custom_authorize(session, uri, action):
## your custom authorization logic to determine whether client
## session should be allowed to perform action on uri
if ...
## allow action
return True
else:
## deny action
return False
with the session
being this:
{
"realm": "realm1",
"authprovider": None,
"authid": "VA-TKRAaIT44meQKZ6n5y7wk",
"authrole": "frontend",
"authmethod": "anonymous",
"session": 1849286409148650
}
how can I replicate this in java?
request -> {
if (request.arguments() == null || request.arguments().size() != 3) {
try {
request.replyError(new ApplicationError(ApplicationError.INVALID_PARAMETER));
} catch (ApplicationError e) {
LOGGER.log(Level.FINE, "There was an ApplicationError", e);
}
} else {
//Something?
}
}
Does this lib support wss? I didnt find any mention of it...
It seems that if I try to serialize a large byte array in a publish message the subscriber side disconnects and fails.
Hi -
I'm interested in supporting Autobahn JS on the client side from a Tomcat server - how big a deal would it be to rehost Jawama from Netty to Tomcat's Websockets API? I've done some programming against Tomcat's inner APIs (e.g., a custom realm), but know essentially nothing about Netty.
Thanks!
Publisher still gets the message without adding the flag "dontExcludeMe" to override the default true exclude_me flag
Is it possible to get actual topic name when using wild card subscription? Right now only message is available and there is no way to get the actual topic name
I'm getting "invalid_uri" error when trying to subscribe to feed "BTC_XMR". Here is the code to reproduce.
public static void main(String[] args) {
try {
WampClient client = new WampClientBuilder()
.withUri("wss://api.poloniex.com")
.withRealm("realm1")
.build();
// open connection
client.open();
// subscribe to connection status events
client.statusChanged()
.observeOn(Schedulers.newThread())
.subscribe((WampClient.Status status) -> {
switch (status) {
case Connected:
System.out.println("INFO - CONNECTED");
// perform subscriptions
client
.makeSubscription("BTC_XMR")
.observeOn(Schedulers.newThread())
.subscribe(
(x) -> {
System.out.println(toPrettyJSON(x));
},
Throwable::printStackTrace
);
break;
case Disconnected:
System.out.println("INFO - DISCONNECTED");
break;
case Connecting:
System.out.println("INFO - CONNECTING");
break;
default:
throw new IllegalStateException("unknown status");
}
});
bearSleep(50000);
client.close();
} catch (WampError e) {
e.printStackTrace();
}
}
bearSleep and toPrettyJson can be replaced with something more simple.
exception i get for this is
ApplicationError(wamp.error.invalid_uri, [], {})
at ws.wamp.jawampa.internal.UriValidator.validate(UriValidator.java:77)
Please fix this, i'm blocked because of this issue...
Is wamp fall into category of topic-based publish-subscribe middleware? how is different from content-based publish/subscribe middleware like padres and IBM Gryphon ?
I ran into an issue using jawampa against a WAMP server which includes uppercase characters in certain topics. This provokes an exception from UriValidator. Any chance you can throw some A-Z into the regexps and/or disable the matcher's case sensitivity?
Hello,
I would like to subscribe to a wildcard wamp topic (i.e. "*"). I am using SubscriptionFlags.Wildcard with a topic name of empty string "". (see the code below). But the msg was not received.
Could you give me some idea and example code (preferred) on how the wildcard subscription would work? Thanks
----code-----
wampclient.makeSubscription("", SubscriptionFlags.Wildcard, String.class)
.observeOn(rxScheduler)
.subscribe(new Action1() {
@OverRide
public void call(String eventDetails) {
LOG.debug("event for 'onhello' received: " + eventDetails.toString());
}
});
BTW, another subscribe API shown as below does not work either.
wampclient..makeSubscription("", SubscriptionFlags.Wildcard, String.class);
Regards,
Jun
I am interested in using javampa to allow WildFly services and Java Clients to communicate together. Currently I am using CORBA but am looking for viable alternatives. Can javampa be run inside of WildFly? Thanks, David
As it seems, this was already done with #46 but the version containing the fix never got it to maven. Can you up the version there?
When you (on client side) register a procedure to be remotely called, you only get a Request object per call. The Request object contains no session information and no methods to retrieve it.
Suggestion:
Allow for flags likedisclose_caller
when registering procedures and give this information to the Request object for retrieval.
Is it possible to get server response for open() method ?
I have application server in Java and I'm using WAMP for communication between client and server. Everything works fine, But now I want to load test this application , So I have written simple Java program, which creates unique thread for each server request. When I run this program a weird thing happens and I have no clue why it is happening this way, When I create more than 120 threads, for many threads I get statusChanged as disconnected. Am I missing something here? Below 120 threads every thread gets connected to server. Can anyone guide me?
If a client is using custom Jackson serializers for its objects, it would be useful to be able to register them with the ObjectMapper used in the WampClient, so that objects with custom serializers are serialized/deserialized properly - see external serializer example using modules on http://wiki.fasterxml.com/JacksonHowToCustomSerializers. Currently because it's not exposed, it's limited to using POJO or annotations, and cannot support modules.
Could we either expose the objectMapper field in the WampClient through a getter, or allow a custom ObjectMapper to be passed when building the client?
I can probably create a pull request for either, but wanted to discuss it first.
Hi, when registering a procedure (i.e. registerProcedure method) I would like to specify registration options for shared registrations (one of 'single' / 'roundrobin' / 'random' / 'first' / 'last') and matching (one of 'exact' / 'prefix' / 'wildcard').
The latter seems possible with event subscriptions via SubscriptionFlags enum but not with procedure registrations.
I'm trying to take advantage of the crossbar.io implemented shared procedure registrations:
http://crossbar.io/docs/Shared-Registrations/
and pattern based procedure registrations:
http://crossbar.io/docs/Pattern-Based-Registrations/
Is this possible today or planned for the near future? Thanks.
Is there a WAMP authentication implementation coming soon?
Not sure if this is already possible, but it should be fairly easy to remove any hard Netty dependencies and instead have the transport be pluggable.
My client code gets tripped up whenever a wamp.error.no_such_procedure
is received, because it seems to always get null as both the array arguments and keyval arguments.
Is this intended, because WAMP allows RPC calls to optionally omit empty array and keval arguments? In that case, perhaps the client should be giving me empty JSON nodes ([]
or {}
) by default if I try to fetch the nonexistent arguments.
Hello,
I was wondering if this solution is a single server solution... I could not find anything talking about how to run a cluster.
Thanks!
-sean
I notice that your internal URI validator only accepts "a.b.c..." with no acceptance for forward slashes. Since the WAMP specification says that a realm name can be any URI, I naturally assumed that slashes could be included, such as "a.b/c" and I was surprised to find that jawampa didn't support it. While designing the library, how did you arrive at your decision to exclude forward slashes? Did you find any resources that specified more strict requirements for the URIs, and if so can you point me to them?
Currently when you subscribe to a topic via makeSubscription, there's no way to know if/when the subscription succeeded, as the observable returned only provides the PubSubData when something is published to the topic.
I have the following scenario where I create a "dynamic" topic, Ie. the topic has some filter information associated with it. So basically I subscribe to the topic from my client with a generated topic name, then I call a procedure registered on the router supplying the topic URI and my filter information, allowing the publisher to start publishing data to my dynamic topic. This results in a race though. Consider this:
Now the published event is received by the subscribed client, but can dropped because subscription on client has not been fully created, due to the result of the initial subscription request being processed on another thread in WampClient (scheduler) where it adds it to the map. The event can be received before or after the subscribe result is processed, resulting in a race.
If I knew when the subscription actually we finished successfully, I could then wait to call "createSubscription" to start getting data, but I can't because I don't know anything about the status of the subscription internally.
I also don't really have a good suggestion about how to fix this either.
I tried to find any properties for Caller Identification feature but not found. Do you have any plans to support this?
Is it possible to set a debug flag in Jawampa? In Autobahn's Python, JavaScript and C++ clients one can do that and get more detailed console output. This is helpful for debugging.
Hi,
I want to use library in Android project with proguard. Does anybody know how to configure proguard to make Jawampa work correctly?
Hello, I'm using this library in my project for retrieve data by WebSocket. I have Pojos and use Jackson to convert results of rest calls (I also have rest calls) to them. One of the objects came also from WebSocket, and jawampa has it's own objectMapper (default object mapper) to provide converting from json to Pojo.
The problem is, that I have to setup my objectMapper by introducing CAMEL_CASE_NAMING_STRATEGY and also setting FAIL_ON_UNKNOWN_PROPERTIES to false, to provide not full mapping from json to objects (my objects are far less, than response json from server). So it would be nice If I could configure objectMapper in jawampa.
For example, It would be greate if WampClientBuilder had method objectMapper(ObjectMapper objectMapper) or something like that.
Thank you.
I'm trying to avoid creating any junk objects, including those that lib creates (PubSub...) and just process incomming data while its byte[] how do we do this?
is it possible at all with jawamp?
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.