Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Question: how to close the websocket connection? #431

Open
LeoAlmDiniz opened this issue Jul 21, 2022 · 1 comment
Open

Question: how to close the websocket connection? #431

LeoAlmDiniz opened this issue Jul 21, 2022 · 1 comment

Comments

@LeoAlmDiniz
Copy link

LeoAlmDiniz commented Jul 21, 2022

I'm using the lib with Spring. So I used a bean to initiate the WebSocket connection.

@Configuration
public class WebSocketConfig {
	@Autowired
	OperationParametersDTO operationParametersDTO;
	@Bean
	public BinanceApiWebSocketClient binanceApiWebSocketClient() {
		BinanceApiWebSocketClient bean = BinanceApiClientFactory.newInstance().newWebSocketClient();
		bean.onCandlestickEvent(operationParametersDTO.getOperationPair().toLowerCase(),
                CandlestickInterval.ONE_MINUTE,
                new BinanceApiCallback<CandlestickEvent>() {	
					@Override
					public void onResponse(CandlestickEvent ce) {
						System.out.println(ce);
					}
				}
		);
		return bean;
	}
}

However, when I close the connection, it keeps listening to events.

`
// ... closer controller logic
binanceApiWebSocketClient.close();
binanceApiWebSocketClient = null;
//... closer controller logic
`

Am I doing something wrong here?

@LeoAlmDiniz
Copy link
Author

P.S.: obviously, I'm Autowiring binanceApiWebSocketClient. System.out.println(binanceApiWebSocketClient.hashCode()) confirm it is the same object.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant