Skip to main content

ping

A builder function that creates a ping interaction to test connectivity to the Flow Access Node.

The ping interaction is a simple way to test if the Flow Access Node is reachable and responding. This is useful for health checks, connectivity testing, and debugging network issues.

Import​

You can import the entire package and access the function:


_10
import * as fcl from '@onflow/fcl';
_10
_10
fcl.ping();

Or import directly the specific function:


_10
import { ping } from '@onflow/fcl';
_10
_10
ping();

Usage​


_26
import * as fcl from '@onflow/fcl';
_26
_26
// Simple ping to test connectivity
_26
try {
_26
const response = await fcl.send([fcl.ping()]);
_26
console.log('Access Node is reachable');
_26
} catch (error) {
_26
console.error('Access Node is not reachable:', error);
_26
}
_26
_26
// Use ping for health checks
_26
const healthCheck = async () => {
_26
try {
_26
await fcl.send([fcl.ping()]);
_26
return { status: 'healthy', timestamp: new Date().toISOString() };
_26
} catch (error) {
_26
return {
_26
status: 'unhealthy',
_26
error: error.message,
_26
timestamp: new Date().toISOString(),
_26
};
_26
}
_26
};
_26
_26
const health = await healthCheck();
_26
console.log('Health status:', health);

Returns​


_10
export type InteractionBuilderFn = (
_10
ix: Interaction,
_10
) => Interaction | Promise<Interaction>;

A function that processes an interaction object


Rate this page