code 2 error and then forced disconnect?

Hi everybody,

I’m using the testnet to see how the api reacts to errors. Specifically, I’ve been trying to subscribe to a list of streams, some of which do not exist, i.e. [“btcusdt@kline_1m”,“doesnotexist@kline_1m”]

I get the expected {‘result’: None, ‘id’: 1} for the first subscription request, and then the (also) expected {‘error’: {‘code’: 2, ‘msg’: ‘Invalid request: invalid stream’}, ‘id’: 2} for the second subscription request.

The problem is that the server seems to disconnect me after the error. Is this the expected behaviour of the server? One error and you are out? =)

Kind regards, Manu

Meanwhile I found the server is (probably) sending a 1008 code (policy violation) when closing the connection.

It make sense to send an error back because the stream doesn’t exist, but to consider it a policy violation and close the connection seems a bit excessive?

You may wish to debug the error and reconnect with correct stream name.

@Dino, debugging the issue is what I’m trying to do here. The error seems to be server-side though. If I subscribe to 10 streams and one is wrong, the error should inform me about the wrong one and subscribe my application to the 9 streams that are correct. Instead the server seems to kick me out.

Notice that I am issuing subscription requests separately instead of one requests for all streams. So, I would expect most requests to go smoothly and one fail without affecting the connection.