Home Backend Development PHP Tutorial Some issues regarding the WeChat public account receiving data and transmitting it to the LAN website

Some issues regarding the WeChat public account receiving data and transmitting it to the LAN website

Aug 18, 2016 am 09:16 AM
mysql php python WeChat public account

I just want to find some ideas and listen to the opinions of experts. I don’t ask others to help me make detailed plans, I just want to point out the direction of research. I know PHP/Java and can write a little Python compared to Baidu.
In the local LAN, there is a server running a php website. This server is in a deep intranet (dynamic public IP + network management does not do port forwarding); there is another server in the computer room of xx cloud, with an independent Public IP, running php to connect with WeChat. Now I want to create a function that allows the information sent by WeChat to be forwarded to the server in the LAN through the xx cloud host. The xx cloud host is a Linux operating system, which can be used to run PHP/Python/Java; the LAN host is an ordinary PC with a windows operating system, which can run PHP/Python/Java. Both hosts are equipped with MySQL databases (also this question The selected database). I wonder if you have any more subtle ideas. .
Now I have a few preliminary ideas, and I would like your comments, thank you!
1. WeChat->Cloud Host (PHP)->Database
The local area network uses Python or Java to poll to obtain new data to the local database.
2. WeChat -> Cloud Host (PHP) -> Cross-process transmission to the Socket server written in Python
The local area network uses Python or Java to establish a Socket link with the cloud host, and the real-time communication is stored in the database.
3. WeChat->Cloud Host (PHP)->Database.
The local database and the remote database are created to synchronize the master-slave database (the key is that the remote can only write without checking)
4. WeChat->Cloud Host (PHP) -& gt; Database t Local writing program directly connects two databases to do some operations. .
The above are some of the results of my thinking on this issue. I feel that each method will affect the speed and efficiency of the overall system.

Reply content:

I just want to find some ideas and listen to the opinions of experts. I don’t ask others to help me make detailed plans, I just want to point out the direction of research. I know PHP/Java and can write a little Python compared to Baidu.

In the local LAN, there is a server running a php website. This server is in a deep intranet (dynamic public IP + network management does not do port forwarding); there is another server in the computer room of xx cloud, with an independent Public IP, run php to connect with WeChat. Now I want to create a function that allows the information sent by WeChat to be forwarded to the server in the LAN through the xx cloud host. The xx cloud host is a Linux operating system, which can be used to run PHP/Python/Java; the LAN host is an ordinary PC with a windows operating system, which can run PHP/Python/Java. Both hosts are equipped with MySQL databases (also this question The selected database). I wonder if you have any more subtle ideas. .
Now I have a few preliminary ideas, and I would like your comments, thank you!
1. WeChat->Cloud Host (PHP)->Database
The local area network uses Python or Java to poll to obtain new data to the local database.
2. WeChat -> Cloud Host (PHP) -> Cross-process transmission to the Socket server written in Python
The local area network uses Python or Java to establish a Socket link with the cloud host, and the real-time communication is stored in the database.
3. WeChat->Cloud Host (PHP)->Database.
The local database and the remote database are created to synchronize the master-slave database (the key is that the remote can only write without checking)
4. WeChat->Cloud Host (PHP) ->Database
          Write a program locally to directly connect the two databases to perform some operations. .
The above are some of the results of my thinking on this issue. I feel that each method will affect the speed and efficiency of the overall system.

You can use the subscription/publishing function of redis, and messages can be delivered instantly

Let me add thickness to your second idea

WeChat->Cloud Host (PHP)->Start a rabbitMQ message queue server, throw the WeChat message into the queue->The LAN host starts a rabbitMQ client, retrieve the message from the server->Throw it into the database

The entire message transmission process is carried out asynchronously, and there will be no blockage in any link. It is done properly and there is no need to reinvent the wheel

There are many options, just like 1, 2, 3, and 4 you gave yourself. At this time, it depends on the business scenario:

  1. Are you pressed for time?

  2. Is the data volume large?

  3. Are the latency requirements high?

  4. How is the concurrency?

  5. Is there any limit on hardware and software investment?

Can’t you use peanut shells

These 4 solutions are all feasible in theory. But remember to pay attention to these points in actual scenarios:
1. All your solutions are write operations. If there are read operations, some solutions will be difficult to handle. If you rely on asynchronous polling, there will definitely be data inconsistency. 2. If you maintain a long connection for communication, if there is no data in a short period of time, will the firewall click off your link? This is a
very difficult and very commonbig problem, especially under the terrible premise that the network management does not provide port forwarding. 3. Regarding option 4, will your network delay cause zombies or dirty data to user operations?

China’s network quality is very poor, try to avoid multiple remote servers processing a linear operation, and try to avoid long remote connections.

Generally, when setting up a WeChat server in a local area network, port forwarding is used (if it is a dynamic IP, a dynamic domain name must be configured). Now your PHP server does not process business in essence, but only acts as a proxy. Then I have two options. 1. Build nginx on the public server and use dynamic domain name technology to reverse proxy to your LAN server. 2. Use the service middle Price, such as java's dubbo, can remotely call services in the local area network from the external server

Statement of this Website
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

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Detailed explanation of docker principle Detailed explanation of docker principle Apr 14, 2025 pm 11:57 PM

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

PHP's Purpose: Building Dynamic Websites PHP's Purpose: Building Dynamic Websites Apr 15, 2025 am 12:18 AM

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

How is the GPU support for PyTorch on CentOS How is the GPU support for PyTorch on CentOS Apr 14, 2025 pm 06:48 PM

Enable PyTorch GPU acceleration on CentOS system requires the installation of CUDA, cuDNN and GPU versions of PyTorch. The following steps will guide you through the process: CUDA and cuDNN installation determine CUDA version compatibility: Use the nvidia-smi command to view the CUDA version supported by your NVIDIA graphics card. For example, your MX450 graphics card may support CUDA11.1 or higher. Download and install CUDAToolkit: Visit the official website of NVIDIACUDAToolkit and download and install the corresponding version according to the highest CUDA version supported by your graphics card. Install cuDNN library:

Python vs. JavaScript: Community, Libraries, and Resources Python vs. JavaScript: Community, Libraries, and Resources Apr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

How to call docker lnmp How to call docker lnmp Apr 15, 2025 am 11:15 AM

Docker LNMP container call steps: Run the container: docker run -d --name lnmp-container -p 80:80 -p 443:443 lnmp-stack to get the container IP: docker inspect lnmp-container | grep IPAddress access website: http://<Container IP>/index.phpSSH access: docker exec -it lnmp-container bash access MySQL: mysql -u roo

How to install nginx in centos How to install nginx in centos Apr 14, 2025 pm 08:06 PM

CentOS Installing Nginx requires following the following steps: Installing dependencies such as development tools, pcre-devel, and openssl-devel. Download the Nginx source code package, unzip it and compile and install it, and specify the installation path as /usr/local/nginx. Create Nginx users and user groups and set permissions. Modify the configuration file nginx.conf, and configure the listening port and domain name/IP address. Start the Nginx service. Common errors need to be paid attention to, such as dependency issues, port conflicts, and configuration file errors. Performance optimization needs to be adjusted according to the specific situation, such as turning on cache and adjusting the number of worker processes.

See all articles