使用this answer here我想用jawampa连接到Poloniex公共Push API,但是jawampa不能连接。我的代码是:
try
{
WampClientBuilder builder = new WampClientBuilder();
IWampConnectorProvider connectorProvider = new NettyWampClientConnectorProvider();
builder.withConnectorProvider(connectorProvider)
.withUri("wss://api.poloniex.com")
.withRealm("realm1")
.withInfiniteReconnects()
.withReconnectInterval(5, TimeUnit.SECONDS);
client = builder.build();
}
catch (Exception e)
{
return;
}
client.statusChanged().subscribe(new Action1<WampClient.State>()
{
@Override
public void call(WampClient.State t1)
{
if (t1 instanceof WampClient.ConnectedState)
{
System.out.println("subscribing...");
Subscription subscription = client.makeSubscription("ticker")
.subscribe((s) -> { System.out.println(s.arguments()); });
}
else
System.out.println(t1.getClass().toString());
}
});
client.open();
System.out.println("ok");
,输出为:
class ws.wamp.jawampa.WampClient $ DisconnectedState
确定
class ws.wamp.jawampa.WampClient $ ConnectingState
然后没有任何反应。我得到它打印出WampClient类名字符串,以帮助理解发生了什么。我做错了什么?
我甚至复制了另一个我发现here的实现,但它仍然无法正常工作。此人的实现提供以下输出:
会话状态已更改为“已断开连接”
会话状态已更改为正在连接
...但是它就像我上面的代码一样挂起。