Giter Club home page Giter Club logo

Comments (8)

jnidzwetzki avatar jnidzwetzki commented on May 31, 2024

Hi,

The API of Bitfinex is sometimes unstable and the driver needs a few connection attempts until a connection is established. According to the exception, you get the HTTP error 400 (Response code was not 101: 400) back from Bitfinex. Please wait a few minutes and try it again.

Best Regards
Jan

from bitfinex-v2-wss-api-java.

cymp avatar cymp commented on May 31, 2024

Hello @jnidzwetzki,

Still does not work, but works with my custom websocket code sample.

from bitfinex-v2-wss-api-java.

jnidzwetzki avatar jnidzwetzki commented on May 31, 2024

Hi,

Up to now I have not been able to reproduce the problem. Could you post an example to reproduce the issue?

Best Regards
Jan

from bitfinex-v2-wss-api-java.

cymp avatar cymp commented on May 31, 2024

I have just used the example:

public static void main(String[] args) {
BitfinexApiBroker bitfinexApiBroker = new BitfinexApiBroker("xxx", "yyy");
try {
bitfinexApiBroker.connect();
} catch (APIException e) {
log.error("Could not connect to Bitfinex API", e);
}
}

and I get:

15:37:49.369 [main] DEBUG com.github.jnidzwetzki.bitfinex.v2.SequenceNumberAuditor - Resetting sequence auditor
15:37:49.378 [main] DEBUG com.github.jnidzwetzki.bitfinex.v2.SequenceNumberAuditor - Resetting sequence auditor
15:37:49.747 [main] ERROR test.BitfinexWebSocketClient2 - Could not connect to Bitfinex API
com.github.jnidzwetzki.bitfinex.v2.entity.APIException: javax.websocket.DeploymentException: Handshake error.
at com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker.connect(BitfinexApiBroker.java:330)
at test.BitfinexWebSocketClient2.main(BitfinexWebSocketClient2.java:75)
Caused by: javax.websocket.DeploymentException: Handshake error.
at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:285)
at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:172)
at com.github.jnidzwetzki.bitfinex.v2.WebsocketClientEndpoint.connect(WebsocketClientEndpoint.java:87)
at com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker.connect(BitfinexApiBroker.java:321)
... 1 common frames omitted
Caused by: org.glassfish.tyrus.websockets.HandshakeException: Response code was not 101: 400
at org.glassfish.tyrus.websockets.HandShake.validateServerResponse(HandShake.java:314)
at org.glassfish.tyrus.websockets.draft06.HandShake06.validateServerResponse(HandShake06.java:98)
at org.glassfish.tyrus.container.grizzly.WebSocketFilter.handleClientHandShake(WebSocketFilter.java:368)
at org.glassfish.tyrus.container.grizzly.WebSocketFilter.handleHandshake(WebSocketFilter.java:353)
at org.glassfish.tyrus.container.grizzly.WebSocketFilter.handleRead(WebSocketFilter.java:274)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:837)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:748)
15:37:49.746 [Grizzly-worker(1)] INFO com.github.jnidzwetzki.bitfinex.v2.BitfinexApiBroker - Closing websocket: CloseReason[1000,Closing]

Process finished with exit code 0

from bitfinex-v2-wss-api-java.

jnidzwetzki avatar jnidzwetzki commented on May 31, 2024

Hi,

I'm sorry, but I was unable to reproduce the problem. Your test code works fine for me.

  • Which Java version do you use?
  • If you have a static IP address, could you try to connect from a different IP?

Best Regards
Jan

from bitfinex-v2-wss-api-java.

cymp avatar cymp commented on May 31, 2024

Hello,

  • I am using Java 8

  • I tried from a different IP, it didn't change a thing. In the meantime, I have developped my own bitfinex WS implementation, but I would be happy to help if I can.

from bitfinex-v2-wss-api-java.

jnidzwetzki avatar jnidzwetzki commented on May 31, 2024

Hello,

Could you try to add the following class to your project and execute it? Is this class able to establish a connection or do you see an exception?

import java.net.URI;

import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.ContainerProvider;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;

import com.google.common.base.Throwables;

@ClientEndpoint
public class WebsocketTest {
	
	public final static String BITFINEX_URI = "wss://api.bitfinex.com/ws/2";
	
	public static void main(String[] args) throws Exception {
		final WebsocketTest websocketTest = new WebsocketTest();
		websocketTest.connect();
	}
	
	private void connect() throws Exception {
		final WebSocketContainer container = ContainerProvider.getWebSocketContainer();
		final URI bitfinexURI = new URI(BITFINEX_URI);
		container.connectToServer(this, bitfinexURI);
		Thread.sleep(100000);
	}

	@OnOpen
	public void onOpen(final Session userSession) {
		System.out.println("Websocket is now open");
	}
	
	@OnClose
	public void onClose(final Session userSession, final CloseReason reason) {
		System.out.println("Closing websocket: " + reason);
	}

	@OnMessage
	public void onMessage(final String message) {
		System.out.println("Got message: " + message);
	}
	
	@OnError
	public void onError(final Session session, final Throwable t) {
		System.out.println("OnError called:" + Throwables.getStackTraceAsString(t));
	}
}

Best Regards
Jan

from bitfinex-v2-wss-api-java.

jnidzwetzki avatar jnidzwetzki commented on May 31, 2024

Because there is no activity in this issue for several days, I will close the ticket.

If you can reproduce the problem, you are welcome to re-open the ticket.

from bitfinex-v2-wss-api-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.