
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!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.






