Views: 460
Last Modified: 10.03.2021

When user enters a website, user's browser, desktop or mobile application establishes and maintains continuous connection with Push server.

  How does Push server works

Usually, Push server uses WebSocket Websockets is a technology that opens continuous bidirectional
network connection between user browser and a server.
You can use it for sending a message to the server, to receive a reply
without a http query.
This process will be event-based.

, is used by 95% of modern browsers. And even if WebSocket is not supported by a browser, it uses Long Polling Also known as "Pending request queue". Brief diagram is as follows:
1. Request is sent to server
2. Connection is not closed by the server until event is initiated
3. Event is sent in response to the request
4. Client immediately sends new pending request

— continuous long polling. It is ajax request AJAX (Asynchronous Javascript And Xml») – server querying technology without page reload , and awaits for a server response during 40-second period. When response is received or timeout is reached, request is repeated.

Bitrix24 Self-hosted uses its own Push server:

  Push server operation procedure


  • User writes a message on a Bitrix24 account (portal).
  • Message is received at NGINX server NGINX server - powerful event-managed web server architecture . NGINX server processes and maintains multiple TCP and HTTPS connections, balances the load and executes other important feature, such as HTTP caching and use as the reverse proxy.
  • Message is sent to PHP-backend portion, saved within it and then transmitted to Push server.
  • Push server consists of Node.js Node.js — software platform, based on V8 engine (translating JavaScript into machine code), converting JavaScript from highly specialised language into universal programming language.
    Learn more...
    eight app processes: 6 processes service are inbound connections, 2 processes are responsible for message publishing.
  • All eight processes of Node.js-application have persistent connection with Redis Redis - non-relational datastore based on key‑value" pair. It stores not only key-value, but also key-dictionary, key-list, i. e. more complex data structures. Learn more... . Redis stores all messages, channel statistics and online status.
  • The message itself contains all data attributes, i. e. author, recipient and etc. One of two processes, responsible for message publication, receives this message, processes and publishes it in Redis.
  • Redis writes the message and notifies other six processes about a new message with optional forwarding to subscribers.
  • WebSocket operation uses open-source Open-source software users have rights for its unrestricted installation, launch, free use, study, distribution and modification, as well as copy and resulting updates propagation Node.js module named ws.
  • Each user receives unique channel ID upon connection with Push server for secure operation. It is a random string consisting of 32 characters with added special signature, unique for this specific channel ID. The channels themselves are regularly switched as well as their IDs.
  • The channel itself is stored at the server for 24 hours, but data is written into it during no longer than 12-hour period. The rest of the time is needed for the user to get previously sent messages. Now, for example, if during an event time a laptop went into "sleep mode" with one single ID, it will "wake up" in the next morning with the same ID and will query a server. After керу message is sent, the server will close the old channel and will create a new channel fo this user.
  All Bitrix24 Push server operation modes

For Bitrix24 Self-hosted, it is recommended to use BitrixVM Bitrix Virtual Appliance - is a free-of-charge, off-the-shelf software product, a fully preconfigured and tested virtual server adapted for an immediate use for both Bitrix24 products and any PHP applications. Available versions of Bitrix Virtual Appliance support both Windows and Unix systems.
Learn more...
, where everything is already configured. When, for some reasons, BitrixVM cannot be used, configure Push server in the employed virtual environment.

You can download Push server source files from Bitrix Virtual Appliance at this address: /opt/push-server/.

Settings are stored in the file config/config.json .

An example for configuring and launching Push server on a third-party environment is provided in this lesson.




Courses developed by «Bitrix», Inc.