{"id":16535,"library":"solclientjs","title":"Solace Messaging API for JavaScript","description":"The `solclientjs` package provides a JavaScript API for connecting Node.js, browser, and mobile applications to a Solace Event Broker. It enables applications to send and receive messages using various messaging patterns like publish/subscribe. The current stable version is 10.18.3, and it follows a regular maintenance and update cadence, often tied to Solace Event Broker releases. Key differentiators include its focus on high-performance messaging specifically with Solace Event Brokers, offering distinct API variations (Debug, Full, Production) that balance performance optimization, minification, and logging verbosity. This library is designed for robust enterprise messaging environments, providing a programmatic interface to Solace's advanced messaging capabilities. It is proprietary software intended solely for use with a Solace Event Broker under specific license terms.","status":"active","version":"10.18.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","messaging","mq","solace","pubsub","microservices","typescript"],"install":[{"cmd":"npm install solclientjs","lang":"bash","label":"npm"},{"cmd":"yarn add solclientjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add solclientjs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"In CommonJS, `require('solclientjs')` loads the `production` API variation by default. In ESM, `import * as solace from 'solclientjs'` provides the module namespace from which all API components (including `SolclientFactory`, `SessionProperties`, etc.) are accessed.","wrong":"import solace from 'solclientjs';","symbol":"solace","correct":"import * as solace from 'solclientjs';"},{"note":"This debug variation includes all logging for easier debugging and is not minified. In CommonJS, it's accessed as `require('solclientjs').debug`.","wrong":"import { debug } from 'solclientjs';","symbol":"solaceDebugAPI","correct":"import * as solace from 'solclientjs'; const solaceDebugAPI = solace.debug;"},{"note":"TypeScript types for core objects and enums, like `Session`, `Message`, and `SessionEventCode`, are typically exported directly from the main package root for strong typing and autocompletion.","wrong":"import { SolaceSession, SolaceMessage } from 'solclientjs';","symbol":"Session, Message, SessionEventCode","correct":"import { Session, Message, SessionEventCode } from 'solclientjs';"}],"quickstart":{"code":"import * as solace from 'solclientjs';\n\nconst host = process.env.SOLACE_HOST ?? 'localhost:55555';\nconst vpn = process.env.SOLACE_VPN ?? 'default';\nconst user = process.env.SOLACE_USERNAME ?? 'client_username';\nconst password = process.env.SOLACE_PASSWORD ?? 'client_password';\n\nconst sessionProperties = new solace.SessionProperties();\nsessionProperties.url = host;\nsessionProperties.vpnName = vpn;\nsessionProperties.userName = user;\nsessionProperties.password = password;\n\nconst session = solace.SolclientFactory.createSession(sessionProperties,\n    new solace.MessageRxCBInfo((session, message) => {\n        console.log(`Received message: ${message.getSdtContainer().getValue()} from topic: ${message.getDestination().getName()}`);\n        message.destroy(); // Important to destroy messages after processing\n    }),\n    new solace.SessionEventCBInfo((session, event) => {\n        console.log(`Session Event: ${event.sessionEventCode} - ${event.infoStr}`);\n        if (event.sessionEventCode === solace.SessionEventCode.UP_NOTICE) {\n            console.log('Session connected successfully.');\n            session.subscribe(\n                solace.SolclientFactory.createTopic('tutorial/topic'),\n                true, // generate confirmation\n                'my-subscription', // correlation key\n                10000 // timeout (ms)\n            );\n            const message = solace.SolclientFactory.createMessage();\n            message.setDestination(solace.SolclientFactory.createTopic('tutorial/topic'));\n            message.setSdtContainer(solace.SDTContainer.create('Hello from solclientjs!'));\n            session.send(message);\n            console.log('Message sent to tutorial/topic');\n        } else if (event.sessionEventCode === solace.SessionEventCode.DISCONNECTED) {\n            console.log('Session disconnected.');\n            session.destroy();\n        }\n    })\n);\n\ntry {\n    session.connect();\n    console.log('Attempting to connect to Solace broker...');\n} catch (error: any) {\n    console.error(`Error connecting: ${error.message}`);\n}\n\n// Keep the process alive for a bit to receive messages\nsetTimeout(() => {\n    if (session.isConnected) {\n        session.disconnect();\n    }\n    console.log('Exiting example.');\n    process.exit(0);\n}, 10000); // Disconnect after 10 seconds","lang":"typescript","description":"This example demonstrates how to connect to a Solace Event Broker, subscribe to a topic, and publish a message using the `solclientjs` API."},"warnings":[{"fix":"Review the Solace software license terms at https://solace.com/license-software before using this package, as it is proprietary and intended for use with Solace Event Brokers.","message":"Proprietary Software License","severity":"gotcha","affected_versions":"*"},{"fix":"API documentation is no longer bundled with the package; refer to the online documentation for Node.js (https://docs.solace.com/API-Developer-Online-Ref-Documentation/nodejs/index.html) or Browser (https://docs.solace.com/API-Developer-Online-Ref-Documentation/js/index.html).","message":"External Documentation","severity":"gotcha","affected_versions":"*"},{"fix":"Choose the appropriate API variation (production, full, or debug) during `require` or `import` based on performance and logging needs. `production` is minified with limited logs, `full` has more logs, and `debug` has all logs with no minification.","message":"API Variation Selection","severity":"gotcha","affected_versions":"*"},{"fix":"After receiving and processing a message, call `message.destroy()` to release associated resources and prevent memory leaks. This is critical for high-throughput applications.","message":"Mandatory Message Destruction","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Verify `sessionProperties.url`, `vpnName`, `userName`, `password` against your Solace Event Broker configuration. Ensure the broker is running and accessible from the client's network.","cause":"Incorrect broker host/port, invalid VPN, username, or password, or broker is unreachable/down.","error":"Error connecting: Solace error 500: Connection refused (client-connect-failed)"},{"fix":"Check topic permissions for the client username and ensure the topic syntax is correct and allowed by the broker's Access Control Lists (ACLs).","cause":"The client attempted to subscribe to a topic for which it lacks permissions on the Solace Event Broker.","error":"Session Event: 18 - Subscription Error: Client does not have 'subscribe' permission for topic 'some/forbidden/topic'."},{"fix":"Ensure you are importing `solace` correctly as `import * as solace from 'solclientjs';` for ESM/TypeScript or `const solace = require('solclientjs');` for CommonJS. `SolclientFactory` should then be accessible as a property of the main `solace` object.","cause":"Incorrect import or access method for the `SolclientFactory`. The `solace` object might not be correctly resolving the `SolclientFactory` property.","error":"TypeError: solace.SolclientFactory.createSession is not a function"}],"ecosystem":"npm"}