Support RSocket
Skip to main content

RSocketTCPClient - rsocket-js

The RSocketTCPClient implements the RScocket protocol using the TCP network transport protocol, and is suitable for Server to Server, and other scenarios where raw TCP is available.

note

RSocketTCPClient is not supported in web browser environments. For web browser environments, RSocketWebsocketClient is recommended and supported.

TCP Client Quick Start Example

npm install rsocket-core rsocket-tcp-client
import { RSocketClient } from 'rsocket-core';
import RSocketTCPClient from 'rsocket-tcp-client';

async function createClient(options) {
const client = new RSocketClient({
setup: {
dataMimeType: 'text/plain',
keepAlive: 1000000, // avoid sending during test
lifetime: 100000,
metadataMimeType: 'text/plain',
},
transport: new RSocketTCPClient({
host: options.host,
port: options.port,
}),
});

return await client.connect();
}

async function run() {
const rsocket = await createClient({
host: '127.0.0.1',
port: 9898,
});

...
}

await run();