search
HomePHP FrameworkWorkermanWhat should I do if the workerman client cannot connect?

What should I do if the workerman client cannot connect?

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Key Features of Workerman's Built-in WebSocket Client?What Are the Key Features of Workerman's Built-in WebSocket Client?Mar 18, 2025 pm 04:20 PM

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

How to Use Workerman for Building Real-Time Collaboration Tools?How to Use Workerman for Building Real-Time Collaboration Tools?Mar 18, 2025 pm 04:15 PM

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

What Are the Best Ways to Optimize Workerman for Low-Latency Applications?What Are the Best Ways to Optimize Workerman for Low-Latency Applications?Mar 18, 2025 pm 04:14 PM

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.

How to Implement Real-Time Data Synchronization with Workerman and MySQL?How to Implement Real-Time Data Synchronization with Workerman and MySQL?Mar 18, 2025 pm 04:13 PM

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

What Are the Key Considerations for Using Workerman in a Serverless Architecture?What Are the Key Considerations for Using Workerman in a Serverless Architecture?Mar 18, 2025 pm 04:12 PM

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

How to Build a High-Performance E-Commerce Platform with Workerman?How to Build a High-Performance E-Commerce Platform with Workerman?Mar 18, 2025 pm 04:11 PM

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.

What Are the Advanced Features of Workerman's WebSocket Server?What Are the Advanced Features of Workerman's WebSocket Server?Mar 18, 2025 pm 04:08 PM

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

How to Use Workerman for Building Real-Time Analytics Dashboards?How to Use Workerman for Building Real-Time Analytics Dashboards?Mar 18, 2025 pm 04:07 PM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

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

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

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

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools