Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const client = new RSocketClient({
serializers: JsonSerializers,
setup: {
dataMimeType: 'application/json',
keepAlive: 100000,
lifetime: 100000,
metadataMimeType: 'application/json',
},
transport: new RSocketWebSocketClient({ url }),
});
client.connect().subscribe({
onComplete: (socket: any) => {
// console.log('Connected to ' + url);
resolve(socket);
},
onError: (error: any) => {
// console.log('Err', error);
async function connect(options: Options): Promise> {
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 new Promise((resolve, reject) => {
client.connect().subscribe({
onComplete: resolve,
onError: reject,
});
function connect(protocol: string, options: ServerOptions) {
const client = new RSocketClient({
setup: {
dataMimeType: 'text/plain',
keepAlive: 1000000, // avoid sending during test
lifetime: 100000,
metadataMimeType: 'text/plain',
},
responder: new SymmetricResponder(),
transport: getClientTransport(protocol, options),
});
return client.connect();
}
TEXT_PLAIN,
MESSAGE_RSOCKET_COMPOSITE_METADATA,
MESSAGE_RSOCKET_ROUTING,
} from 'rsocket-core';
import RSocketWebSocketClient from 'rsocket-websocket-client';
import WebSocket from 'ws';
const maxRSocketRequestN = 2147483647;
const host = '127.0.0.1';
const port = 7000;
const keepAlive = 60000;
const lifetime = 180000;
const dataMimeType = 'application/octet-stream';
const metadataMimeType = MESSAGE_RSOCKET_COMPOSITE_METADATA.string;
const client = new RSocketClient({
setup: {
keepAlive,
lifetime,
dataMimeType,
metadataMimeType,
},
transport: new RSocketWebSocketClient(
{wsCreator: () => new WebSocket('ws://localhost:7000'), debug: true},
BufferEncoders,
),
});
// Open the connection
client.connect().then(socket => {
socket
.requestStream({
constructor(url, responder) {
this.client = new RSocketClient({
serializers: {
data: JsonSerializer,
metadata: JsonMetadataSerializer,
},
setup: {
// ms btw sending keepalive to server
keepAlive: 10000,
// ms timeout if no keepalive response
lifetime: 20000,
dataMimeType: 'application/json',
metadataMimeType: JsonMetadataSerializer.MIME_TYPE,
},
transport: new RSocketWebSocketClient({url: url}),
responder: responder
});
}
initRsocketWebSocket() {
// Create an instance of a client
const client = new RSocketClient({
//serializers: JsonSerializers,
setup: {
// ms btw sending keepalive to server
keepAlive: 60000,
// ms timeout if no keepalive response
lifetime: 180000,
// // format of `data`
dataMimeType: 'application/json',
// format of `metadata`
metadataMimeType: 'x.rsocket.routing.v0',
},
transport: new RSocketWebSocketClient({url: 'ws://localhost:8088/rsocket'}),
});
// Open the connection
client.connect().subscribe({
return new Promise((resolve, reject) => {
const validationError = validateBuildConfig({ URI, keepAlive, lifetime, WebSocket });
if (validationError) {
return reject(new Error(validationError))
}
try {
this._client = new RSocketClient({
serializers: JsonSerializers,
setup: {
keepAlive,
lifetime,
dataMimeType: 'application/json',
metadataMimeType: 'application/json'
},
transport: new RSocketWebSocketClient({ url: URI, wsCreator }),
});
} catch(error) {
return reject(error);
}
this._connect()
.then(resolve)
.catch(error => reject(extractConnectionError(error)))
const connect = async () => new RSocketClient({
setup: RSOCKET_OPTIONS,
transport: new RSocketWebSocketClient({url: RSOCKET_URL}, BufferEncoders)
}).connect();