Skip to content

SpotWebsocketAPI User Data Stream Subscription disconnects after 20 seconds #535

@kBondarchuk

Description

@kBondarchuk

Tested with this example from README.md.

I got this after 20 secs:

{
  e: "eventStreamTerminated",
  E: 1762030622639,
}
import { Spot, SpotWebsocketAPI } from '@binance/spot';

const configurationWebsocketAPI = {
    apiKey: 'your-api-key',
    apiSecret: 'your-api-secret',
};
const client = new Spot({ configurationWebsocketAPI });

client.websocketAPI
    .connect()
    .then((connection) => connection.sessionLogon().then(() => connection))
    .then((connection) => connection.userDataStreamSubscribe())
    .then(({ stream }) => {
        stream.on('message', (data) => {
            switch (data.e) {
                case 'balanceUpdate':
                    console.log('balance update stream', data);
                    break;
                case 'outboundAccountPosition':
                    console.log('outbound account position stream', data);
                    break;
                // …handle other variants…
                default:
                    console.log('unknown stream', data);
                    break;
            }
        });
    })
    .catch((err) => console.error(err));

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