Matthias247 / jawampa

Web Application Messaging Protocol (WAMP v2) support for Java
Apache License 2.0
148 stars 56 forks source link

Cannot connect to the Poloniex wamp server at wss://api.poloniex.com #83

Open luchesar opened 8 years ago

luchesar commented 8 years ago

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);
    }
}
michaelBielang commented 8 years ago

could you solve your Problem? Can you may help me to make it running? I cannot even make a connection to poloniex cause i cannot find a docu for jawampa... I just want to get current prices and to make trades automated (function do i provide ofc) i just need to know how.

TitusI commented 8 years ago

I've no problem to connect to poloniex, but when I get the update only the first field is shown. I'm studing the tavendo wamp protocol from here: https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02 I read it time ago, but now I need to go back and start again. Here is the piece of code who made the subscription and pick the tcker from poloniex server:

` client.statusChanged().subscribe(new Action1() { @Override public void call(WampClient.State t1) { System.out.println("Session status changed to " + t1);

        if (t1 instanceof WampClient.ConnectedState) {
            System.out.println("Client P ricevuto " + t1);

            eventSubscription = client.makeSubscription("ticker", String.class).subscribe(new Action1<String>() {

                        @Override
                        public void call(String t1) {
                        System.out.println("ES ricevuto " + eventSubscription);
                        System.out.println("Client P ricevuto " + t1);
                        }

            });`
michaelBielang commented 8 years ago

Sorry i was not clear enough...i'm struggling with the login...api key & secret. How do i make jawampa running with my key & secret?

andre77 commented 7 years ago

Hi everybody, i have some issues with the poloniex Push API, so decided to use the thread here and not to open a new one

Using the Poloniex Push API we face some weird issues with the sequence number, namely some messages are being dropped and do not arrive on our side. The messages are received with a sequence number inside. We process them directly and change the internal state of the order book, if the seuence is exact one more than last processed one. In case the messages are arriving not in the exact order of sequence numbers, the messages are buffered and processed later in the correct order. So we can handle messages very well independent of the order they arrive in. But the problem, which we can not handle,occurs, if we simply miss a sequence number. It happens pretty often. Currently if we miss a sequence number the messages are buffered, and if the buffer grows over 100 messages, we stop waiting for that missing sequence number. The only thing, we can do, is to start the complete sync process again. We get the snapshot of the order book using the rest API, and apply the incoming messages using the sequence numbers.

The described problem occurs very often, for example if we look at the pair “BTC_ETH”, we see the problem almost twice a minute.

See attached the simple java program PoloniexWSJavampa.java, which can be used to reproduce the issue. One example output is attached as well.

example.output.txt PoloniexWSJavampa.java.txt

The big question here is, how is it possible, that we do not see some messages??? Can they be dropped somehow? By server or by jawampa?

hkothari commented 7 years ago

Andre, this seems to be a problem with the Poloniex API itself. Try running without jawampa and instead use the node autobahn example they provide on their docs. This problem persists there as well so I doubt this is caused by jawampa.

andre77 commented 7 years ago

@hkothari thanks a lot for the reply, actually i'm trying to reach the Poloniex support and get some answers. imho it looks like a server side problem.

JeremieRodon commented 7 years ago

@andre77 Same problem here... I don't know if you guys have logs of the missing numbers ? If you do and we all got the sames, that would definitely be a server side glitch.

Tests made for 1 minute, just before this post : BEGIN : Sun Jan 22 23:48:37 CET 2017 BTC_ZEC : 52 missing [24371601, 24371609, 24371614, 24371625, 24371644, 24371645, 24371658, 24371661, 24371669, 24371691, 24371692, 24371696, 24371714, 24371720, 24371722, 24371725, 24371745, 24371748, 24371750, 24371756, 24371757, 24371821, 24371832, 24371848, 24371852, 24371868, 24371897, 24371917, 24371937, 24371938, 24371942, 24371956, 24371979, 24371990, 24372000, 24372007, 24372015, 24372017, 24372025, 24372027, 24372028, 24372033, 24372044, 24372055, 24372062, 24372064, 24372067, 24372081, 24372099, 24372105, 24372108, 24372120] BTC_ETC : 34 missing [90131072, 90131076, 90131085, 90131100, 90131105, 90131125, 90131133, 90131147, 90131153, 90131175, 90131191, 90131193, 90131196, 90131227, 90131236, 90131244, 90131250, 90131282, 90131325, 90131332, 90131334, 90131343, 90131386, 90131396, 90131408, 90131410, 90131450, 90131455, 90131462, 90131493, 90131510, 90131521, 90131525, 90131533] BTC_ETH : 13 missing [236735378, 236735379, 236735404, 236735419, 236735423, 236735432, 236735442, 236735447, 236735453, 236735469, 236735470, 236735472, 236735497] END : Sun Jan 22 23:49:40 CET 2017

pangiole commented 7 years ago

@andre77 @hkothari @JeremyRodon

I believe there is nothing broken neither in jawampa nor in Poloniex. I'd like to give some detailed insights about the WAMP protocol but I couldn't do it here as this issue was open by @luchesar for different reasons.

Please, open a separate issue to discuss about your understanding of that "supposedly WAMP event sequencing" your client apps are trying to determine.

Please, leave this issue as discussion space relevant to what was originally intended for.

andre77 commented 7 years ago

@angiolep thanks for your reply, lets continue here https://github.com/Matthias247/jawampa/issues/101

andre77 commented 7 years ago

@luchesar sorry to capture your issue

back to the initial problem posted here, if i run your code, it works properly, so maybe it can be closed here... jawampa version 0.4.2

bhavishyagoyal12 commented 7 years ago

I can't run Again and getting following

http.websocketx.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: RpM9+AwVLTb6Wwbb269bOg==, expected response: U63478FdY2NiAkDiEjA5Z/BUdm4= 13:48:21.532 [WampClientEventLoop] DEBUG io.netty.handler.ssl.util.InsecureTrustManagerFactory - Accepting a server certificate: CN=*.poloniex.com, OU=Domain Control Validated 13:48:21.715 [WampClientEventLoop] DEBUG io.netty.handler.ssl.SslHandler - [id: 0x94bfe618, L:/192.168.1.7:54745 - R:api.poloniex.com/104.20.12.48:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 13:48:26.939 [WampClientEventLoop] DEBUG io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: gcbXtu71NXa6TYklXASmRw==, expected response: 87OHuKGmzErfKNYGGAjvXhXf/Ec= 13:48:27.008 [WampClientEventLoop] DEBUG io.netty.handler.ssl.SslHandler - [id: 0x4ad083e0, L:/192.168.1.7:54747 - R:api.poloniex.com/104.20.12.48:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 13:48:32.209 [WampClientEventLoop] DEBUG io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: oIZFqpdX1fN2D26ka5T8OA==, expected response: 7IYQFV+2e7tu8pdJZlSsj3fqNUo= 13:48:32.282 [WampClientEventLoop] DEBUG io.netty.handler.ssl.SslHandler - [id: 0x92a55bf9, L:/192.168.1.7:54748 - R:api.poloniex.com/104.20.12.48:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 13:48:37.441 [WampClientEventLoop] DEBUG io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: Q9UIkbJChC+PZCFL3BTtXQ==, expected response: D/B7nsIR75OAEvx2rP7UfeeyDo4= 13:48:37.511 [WampClientEventLoop] DEBUG io.netty.handler.ssl.SslHandler - [id: 0x7bf8bb9e, L:/192.168.1.7:54750 - R:api.poloniex.com/104.20.12.48:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

Can any one please help me out

stolsvik commented 7 years ago

I have the same problem as @bhavishyagoyal12 - I just get repeated

"io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: /MkHsONZ3QxYFfB84BJUcA==, expected response: BONDn5rFV+vVz8hDryBStKjT3zs=" (differing key and expected response)

.. with following

"io.netty.handler.ssl.SslHandler - [id: 0x68039185, L:/10.10.10.243:42710 - R:api.poloniex.com/104.20.13.48:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"

These two lines go on and on, evidently not establishing connection. It has once (!) - where the Connected event came in, and I could subscribe to the "ticker" channel and started getting updates. I guess this points towards Poloniex having some problem - but what? And how could I mitigate that?

Who is triggering those "handshakes" - from which side is this? Might it be some timeout issue?

qyvlik commented 6 years ago

Use the wss://api2.poloniex.com may can receive data.

https://github.com/qyvlik/digital-currency-exchange-api/issues/19

https://stackoverflow.com/questions/42436264/reading-messages-on-poloniex-trollbox-with-python-autbahn-or-other-socket-module

https://github.com/dutu/poloniex-api-node/blob/master/lib/poloniex.js