Skip to content

accountUnsubscribe error: Tried to call a JSON-RPC method accountUnsubscribe #2106

@Andross96

Description

@Andross96

Hello,

When trying to use Drift SDK to place a perp order, there is a randomly a loopy random error :

accountUnsubscribe error: Tried to call a JSON-RPC method `accountUnsubscribe` but the socket was not `CONNECTING` or `OPEN` (`readyState` was 2)
accountUnsubscribe error: Tried to call a JSON-RPC method `accountUnsubscribe` but the socket was not `CONNECTING` or `OPEN` (`readyState` was 2)
### hundreds of times until crash

This is how I instantiate a DriftClient and how I place a perp order :

// DriftClient init:
const provider = new AnchorProvider(
	connection,
	wallet,
	{
		commitment: 'confirmed',
		preflightCommitment: 'confirmed',
		skipPreflight: false,
	}
);

const driftPublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
const driftClient = new DriftClient({
	connection: provider.connection,
	wallet: provider.wallet,
	programID: driftPublicKey,
	accountSubscription: {
		type: "websocket",
	}
});
await driftClient.subscribe();

// Perp placing order
try {
	await driftClient.placePerpOrder(
		getMarketOrderParams({
			marketIndex: marketIndex,
			baseAssetAmount: assetAmount,
			direction: direction,
		}),
		undefined,
		subAccountId
	);
} catch (e) {
	if (e instanceof SendTransactionError) {
		console.error(e.logs);
	}
	throw e;
}

Using latest "@drift-labs/sdk": "^2.157.0-beta.7" version.
Please advice

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