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

Question: how to close the websocket connection? #431

@LeoAlmDiniz

Description

@LeoAlmDiniz

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions