


Some issues regarding the WeChat public account receiving data and transmitting it to the LAN website
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.
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:
- Are you pressed for time?
- Is the data volume large?
- Are the latency requirements high?
- How is the concurrency?
- 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

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 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.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.

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.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP makes it easy to create interactive web content. 1) Dynamically generate content by embedding HTML and display it in real time based on user input or database data. 2) Process form submission and generate dynamic output to ensure that htmlspecialchars is used to prevent XSS. 3) Use MySQL to create a user registration system, and use password_hash and preprocessing statements to enhance security. Mastering these techniques will improve the efficiency of web development.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.


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

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.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.