In order to use customer service, you must open the long connection. The configuration process of the long connection is slightly complicated, and the server needs to release the port. If it is a pagoda, it needs to release the port in security. If you use HTTPS, you add a WSS configuration, and we’ll go through each configuration in detail.

Note: Customer service ports can be customized. Currently, the system uses ports 20002, 20003, and 20012 by default

Take Ali Cloud server as a reference, enter the server security group port and add release port [20002] [20003]. Of course, you can also release all releases within the range of [20000/30000]. Finally, click Save. The effect is shown below.After the port on the server is allowed, the port on the pagoda is allowed to users who do not use the pagoda and the firewall is enabled

Enter the pagoda background, click the security menu to add release port, you can add a range such as: 20000:20003, fill in the release description, and finally click Save. The effect is shown below.Web sites require HTTPS requests, and WSS needs to be configured. It is important to know that long connections accessed through HTTP must be accessed through WS, and long connections accessed through HTTPS must be accessed through WSS. And you can’t have both. You can’t access both HTTP and HTTPS like a website.

First configure WSS, on the download configuration SSL certificate, here take Nginx as an example, go to Ali cloud SSL certificate center to download the SSL certificate of the current website, download the certificate as a compressed package, there are two files, one file ends in.key, one file ends in.pem. Upload the downloaded certificate to system background Settings -> System Settings -> WSS Configuration. Upload it to the appropriate location as prompted.

Select enable WSS. File ending with SSL certificate PEM. File ending with SSL KEY. Click Submit to save the configurationInsert the picture here to describe the SSL certificate applied directly on the pagoda, how to get the certificate file?Copy ** KEY ** and create a.key file on your desktop.

Copy the ** certificate (PEM format)** and create a.pem file on your desktop; You can then follow the instructions in the previous section

Enabling a long connectionUse the Xshell or Putty remote connection tool to connect to the server

Please unblock the function used to enable long links before starting long links

PCNTL_signalpCNTL_signal_dispatchpCNTL_forkpCNTL_waitpCNTL_alarm Reload the PHP configuration.

Switch to the site root directory for example:

CD/WWW /wwwroot/crmeb/ Run the command to enable the long connection

Sudo -u WWW PHP think workerman start –d It was also mentioned above that long-connected ports are modifiable.Test whether the connection is successful. Open the website on the browser and enter the H5 terminal. Open the browser console and click Network -> WS. [Status Code] the Status is 101 Switching Protocols, as shown in the figure below:The long connection configuration of customer service is complete. The configuration process is slightly complicated, and the general process is as follows

Release long connection on the server to port Whether you need release pagoda long connection to port the HTTPS protocol to access, and if so, you need to configure WSS lifted PHP function to start the long connection testing the success of the above for a detailed description of the long connection configuration of the service, here it is with the Linux system as the core to explain in detail how to open it.

Source code free download address: github.crmeb.net/u/defu