Documentation Home »Developer Cookbook »WebSockets Recipes »Publish Messages to Existing Topics
3.0 version
You are currently viewing documentation for version 3.0 which is not a long-term support release. The latest long-term support release is version 2.6

Publish Messages to Existing Topics

Publish Messages from Backend

To publish to and read messages from WebSocket connections topics on the backend side of Oro application, OroSyncBundle provides a WebSocket oro_sync.websocket_client client which in is based on Gos WebSocketClient component GosComponentWebSocketClientWampClient.

WebSocket client makes use of authentication tickets mechanism, so you should not worry about authentication on the backend side.


WebSocket client oro_sync.websocket_client uses anonymous authentication tickets, so when you connect to WebSocket server, it treats you as an anonymous.

You can publish messages to channels using the publish() method of the oro_sync.websocket_client, e.g.:

$websocketClient = $this->get('oro_sync.websocket_client');
$websocketClient->publish('oro/custom-channel', ['foo' => 'bar']);

It is strongly recommended to use the oro_sync.client.connection_checker connection checker before trying to connect or publish to websocket server, e.g.:

$websocketConnectionChecker = $this->get('oro_sync.client.connection_checker');
if ($websocketConnectionChecker->checkConnection()) {
    $websocketClient = $this->get('oro_sync.websocket_client');
    $websocketClient->publish('oro/custom-channel', ['foo' => 'bar']);

Publish Messages from Frontend

At the moment there is no option to publish messages to websockets topics from the frontend side.

List All Declared Topics

All declared topics for WebSocket connections in your application (that you can subscribe and publish messages to) are declared in the websocket_routing.yml files in Resources/config/oro/ folders in application bundles. You can search all these files and look into them to find all declared topics.


For more details on how to declare topics, see the Create Your Topic and Handler for Publishing and Subscribing topic.

You will be redirected to [title]. Would you like to continue?

Yes No
sso for www.magecore.comsso for oroinc.desso for oroinc.frsso for marketplace.orocommerce.comsso for