workermanWhat should I do if the client cannot connect?
Cause of client connection failure
The client will generally report two errors when the connection fails, connection refuse and connection timeout
connection refuse
Generally the reasons are as follows:
1. The port the client connects to is wrong
2. The domain name the client connects to or The ip is wrong
3. If the client uses a domain name to connect, the domain name may point to the wrong server ip
4. The server is not started or the port is not monitored
5. Network proxy software is used
6. The server monitoring IP and the access address are not in the same address segment. For example, if the server monitors 127.0.0.1, the client can only connect through 127.0.0.1 and cannot connect through LAN IP or external network IP. It is recommended that the listening address be set to 0.0.0.0, so that the local machine, internal network, and external network can connect.
connection timeout
It is usually due to the following reasons:
1. The server firewall blocks the connection. You can temporarily close the firewall and try
2. If it is a cloud server, the security group may also prevent the connection from being established. You need to open the corresponding port in the management background.
3. The server does not exist or is not started.
4. If the client uses a domain name to connect, the domain name may point to the wrong server IP
5. The IP accessed by the client is the server’s intranet IP, and the client and the server are not in the same LAN
Other errors
If the error that occurs is not connection refuse and connection timeout, it is generally due to the following reasons:
1. The communication protocol used by the client is inconsistent with the server.
For example, the server uses the http communication protocol, and the client cannot connect using the websocket communication protocol. If the client connects using the websocket protocol, the server must also use the websocket protocol. If the server is a service of http protocol, then the client must use http protocol to access.
The principle here is similar to that if you want to communicate with British people, then use English. If you want to communicate with Japanese people, use Japanese. The language here is similar to a communication protocol. Both parties (client and server) must use the same language to communicate, otherwise communication will not be possible.
Common errors caused by inconsistent communication protocols are:
WebSocket connection to 'ws://xxx.com:xx/' failed: Error during WebSocket handshake: Unexpected response code: xxx WebSocket connection to 'ws://xxx.com:xx/' failed: Error during WebSocket handshake: net::ERR_INVALID_HTTP_RESPONSE
Solution:
It can be seen from the above two errors that the client uses the ws connection and the websocket protocol . The server also needs to use the websocket protocol. Some of the server-side listening codes need to specify the websocket protocol to communicate, for example, as follows
If it is a gatewayWorker, the listening part of the code is similar
// websocket协议,这样客户端才能用ws://...来连。xxxx为端口不用改动 $gateway = new Gateway('websocket://0.0.0.0:xxxx');
If it is a Workerman Is
// websocket协议,这样客户端才能用ws://...来连。xxxx为端口不用改动 $worker = new Worker('websocket://0.0.0.0:xxxx');
Recommended: workerman tutorial
The above is the detailed content of What should I do if the workerman client cannot connect?. For more information, please follow other related articles on the PHP Chinese website!

Workerman's WebSocket client enhances real-time communication with features like asynchronous communication, high performance, scalability, and security, easily integrating with existing systems.

The article discusses using Workerman, a high-performance PHP server, to build real-time collaboration tools. It covers installation, server setup, real-time feature implementation, and integration with existing systems, emphasizing Workerman's key f

The article discusses optimizing Workerman for low-latency applications, focusing on asynchronous programming, network configuration, resource management, data transfer minimization, load balancing, and regular updates.

The article discusses implementing real-time data synchronization using Workerman and MySQL, focusing on setup, best practices, ensuring data consistency, and addressing common challenges.

The article discusses integrating Workerman into serverless architectures, focusing on scalability, statelessness, cold starts, resource management, and integration complexity. Workerman enhances performance through high concurrency, reduced cold sta

The article discusses building a high-performance e-commerce platform using Workerman, focusing on its features like WebSocket support and scalability to enhance real-time interactions and efficiency.

Workerman's WebSocket server enhances real-time communication with features like scalability, low latency, and security measures against common threats.

The article discusses using Workerman, a high-performance PHP server, to build real-time analytics dashboards. It covers installation, server setup, data processing, and frontend integration with frameworks like React, Vue.js, and Angular. Key featur


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools