Category Archives: How to Fix

JS error: require is not defined

Reasons for error:
The browser side cannot recognize the require keyword, which is required under node.js environment. It is common to require modules in node_modules folder
Solutions:
Compile the JS file with the tools Browserify or WebPack to make it browser-aware.
// Install Browserify, which I’m using as a global installation
npm install -g browserify
//compile
browserify ./source/module.js -o ./dist/dist.js
You can see the packaged Dist. Js file in the dist directory. The first parameter after
browserify represents the entry of the front-end program to be packaged, -o or > Represents the packaged output file. Browserify automatically completes dependency analysis based on require or Import (ES6, need to install Babel) in the entry file and packages the dependency file into a single file.

Analysis of “RSL error 1 of 1”

Recently, I participated in a virtual community Project, in which I made a farm game and video conferencing application module. The whole Project has several Flex projects, including the main program, public library and various functional modules. Because I was a late participant, I did not know much about the development mode of the Project, and of course because the two applications I made were independent, So I used the independent Flex Project to build the two applications.
The project used RSL(Runtime Shared Library) to link external libraries, so I also used RSL when making those two applications. At the beginning, everything was normal. After the project was launched, the customer service staff occasionally received a call from the customer saying that the farm could not be opened, and the location of the farm appeared “RSL Error 1 of 1”, with a paragraph below “Error #2032: flow Error”. URL: http://www.xxx.com/XXX.swf/ [[DYNAMIC]]/framework_3 2.0.3958. SWF.
For a period of time, I was quite confused. At that time, I found the cause of the problem and came up with a solution.
First make a brief introduction of RSL, RSL is to compile multiple Project to create classes to multiple SWF, which includes the class library Project, the Flex framework library (framework_xxx. SWF), so that you can put the SWF contained in class sharing for multiple projects, on the client side load when it is ok to only need to load a (if not using RSL, all use class will compile into a SWF, if there are multiple SWF, repeat each part is contained inside the class, increase the user downloads). In the case of only one Project, the effect of using the RSL is not obvious because the generated SWF needs to be loaded for all other SWF Shared libraries that are used; However, if there are multiple projects, the advantage will emerge. After the first SWF loads the Shared library, the later SWF will not need to be loaded again, which can improve the access speed.
After using RSL, there will be two framework files “framework_3.2.0.3958. SWZ” and “framework_3.2.0.3958. SWF” in the root directory of the generated project (using different Flex SDK, the latter version number of these two framework files will be different). If the framework.swz file fails to load, Flash Player will go to the framework.swf file, one of the two is successfully loaded, and the project will run correctly.
In the event of a “RSL Error” Error, I tried to reproduce this Error on your computer, operating system, using XP when I cancel the SWZ files from the Flash Player cache, and built an empty read-only SWZ files, name and just delete the SWZ file name, to run the project again, and sure enough the “RSL Error”, below, write a new framework for Flash Player to the cache. SWZ failed, at the same time framework. The SWF also failed to load. The solution was to manually save the framework.swz file to the client’s Flash Player cache. I didn’t think much about why the file didn’t load successfully on the client’s computer (maybe it was a permission issue), but I just posted on the forum to see if anyone had a similar problem.

Everyone has a lazy side, which was exactly what I did at that time. If you think about it carefully, there are at least two questions that should be explored: 1. The whole project is using RSL, why only the two applications I wrote have RSL errors, and what is the difference between the application I wrote and the whole project; 2. 2, my application in framework. SWZ failed to load, framework. SWF also failed to load, so it can not run, the whole project in SWZ failed to load, but can run, later look, IE cache does exist framework. SWF, then this can be the whole project file load framework. SWF.
For a while, no one on the forum was sure of a solution to the problem. Once again, let me dig into this problem to help a customer solve the farm can not be opened, that is, there is an “RSL Error”. The client’s computer is Vista and Internet Explorer 8. When I put the framework.swz used in RSL into the client’s Flash cache, it occurred to me that it might be caused by the operating system. We are developing on XP. Because there is no SWZ file in the client’s Flash cache, the previous access failed to load the SWZ at all.
I installed Win7 in the virtual machine to do the test (Win7 and Vista kernel), sure enough, under Win7 can not normally access the farm, Flash cache without SWZ file. Because the project of other modules can be normal visit, so I think framework. The SWF file should be loaded successfully, but when I open the IE cache, find IE cache is framework. SWZ, rather surprised, as the chart, because always thought before the SWZ framework cache files will be saved to Flash, never think under Windows 7 will be put into IE cache (I Flash Player version is 10.0.45), which is why no SWZ framework in the Flash cache files. (If frame. SWZ is in Flash cache, SWFS in multiple domains can be Shared; if in IE cache, SWFS in the same domain can only be Shared).

Discovering this has certainly given me a better understanding of the RSL bug, which could be a bug in Flash Player, or a manipulation of Adobe by Microsoft, but this cannot be confirmed at this time.
Question to this, of course, is not the end, because we have a question: framework. SWZ loading failure, and framework. The SWF can choose ah, why the second choice is also failed, I use firefox HttpFox plugin to view the request to the server client, finally found the problem, and it is concluded that the second question framework. SWF loading failure has nothing to do with the operating system. Summary of the cause of the problem: “Loading an external SWF file that USES an RSL causes an error path to the Framework file that the external SWF points to.”
Firefox browsing, and open the HttpFox plugin to view the Http request, after loading the main routine, can detect the client request the framework. SWZ file (if the SWZ cannot load may be loaded framework. The SWF file), when I disable the SWZ file after loading, into the farm, found the farm reload framework. SWZ and framework. The SWF, but these two files are failed to load, the two pictures below the first one is the main process successfully loaded framework. SWZ, The second path to the Framework file that shows the farm loaded is an error.


The problem is clear, the farm is a separate Project and USES the RSL and is loaded into the main program using Loader. It looks as if this changes the URL path of the farm program, but the resource path used by the farm does not change. So the conclusion should be that only the path of framework file used by this application is changed, and this path is only used in Flash Player, I don’t know if there is any other place to set it, is this another Flash Player bug?
I hope to further study the RSL.
 
PS: I forgot to write the solution in this article. At present, I know of two solutions. One is to stop using the RSL. The second is to manually copy the FlashPlayer cache file to the client. The disadvantage of this method is that sometimes we cannot operate the client. For the second approach, the cache directory of FlashPlayer is: XP system is C:/Documents and Settings/user/Application Data/Adobe Flash Player/AssetCache/H7UC3H3Y, VISTA and Windows 7 system is C:/Users/username/AppData/Roaming/Adobe Flash Player/AssetCache/RAU4Y963, this the end of the two paths a folder name is random, Another copy SWZ file also need to pay attention to in the past, such as FlexSDK3.2 SWZ filename in the cache is 1 c04c61346a1fa3139a37d860ed92632aa13decf. SWZ, this files need to be from a flashplayer cache is a problem with the copy machine to machine.

Error Code: 2006 – MySQL server has gone away

SQLyog reported an error when importing the database
Error Code: 2006-mysql Server has gone Away
Max_allowed_packet (a parameter of MySQL) is not set to a large enough value.
Modify directly using SQL statements:
The SET GLOBAL max_allowed_packet = 671088640;
This works well, after the change, there is no need to restart the service, it works directly

How to solve the error loading media: file could not be played in jwplay

Recent development projects need to use the JWplayer plugin to play videos, but no matter which version or what video is replaced, it always prompts Error loading media: File could not be played incorrectly. At first, I thought it was video coding, but after a lot of work, I still couldn’t solve the problem. Later, I accidentally found that IIS does not support. Mp4 format playback problem.
The IIS default configuration does not add an MP4 file, which results in opening an MP4 file reporting 404. The solution to this problem is simple, as follows:
1. Open IIS Manager


2. Double-click on the MIME type and click Add 22 in the upper right corner of the image below

3. Add, extension mp4, type Video/MP4


4. Click OK
is a perfect solution to the problem

【Exception】mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table…

When backing up mysql data today, I encountered the Error Error 2013. Let’s have a look at the reason.

The scene

-bash-4.1$ mysqldump -uroot -p1234456 tpcms > ~/mysql-backup/tpcms.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `cms_basic` at row: 237

Cause analysis,
Dump volume is so large that it exceeds the set timeout time
As you can see from executing the query below, net_read_timeout is 30 seconds, and net_write_timeout is 90 seconds

mysql> show global variables like '%timeout%';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 10       |
| delayed_insert_timeout      | 300      |
| have_statement_timeout      | YES      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 28800    |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 30       |
| net_write_timeout           | 60       |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 60       |
| wait_timeout                | 28800    |
+-----------------------------+----------+
13 rows in set (0.01 sec)

The solution
After setting timeout up, you can dump

mysql> set global net_read_timeout = 120; 
Query OK, 0 rows affected (0.00 sec)

mysql> set global net_write_timeout = 900;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like '%timeout%';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 10       |
| delayed_insert_timeout      | 300      |
| have_statement_timeout      | YES      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 28800    |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 120      |
| net_write_timeout           | 900      |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 60       |
| wait_timeout                | 28800    |
+-----------------------------+----------+
13 rows in set (0.01 sec)

One of the methods to solve registry error while deleting key


In deleting certain keys, error while deleting key appears.
Because the permissions are SYSTEM (I wonder if someone else has more permissions than me!!).

To take a simple example, right-click a key and click permissions


Click on the advance.


After clicking the Owner


My user name is yanyu, so click second yanyu(yan\yanyu) on the check mark Replace owner on subcontainers and objects and click Apply and OK

To go back to this screen, click Add…


Click on the Advanced…

Click find now and find the last yanyu (the one with only one head)


just click OK

Give the tick under yanyu (YAN\yanyu) Full Control

Click OK

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in E:\WWW\blog\hyii2\frontend\web\index.php

Yii2.0.32. Advanced Templates.
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in E:\WWW\blog\hyii2\frontend\web\index.php on line 17
https://www.imooc.com/qadetail/189883
This is a syntax error,
The first thing you need to do is check the file E:\WWW\blog\hyii2\ Frontend \ Web \index.php for syntax errors on line 17
If you haven’t touched this file, chances are your VERSION of PHP doesn’t meet the requirements
Yii2 requires at least 5.4 PHP versions

Linux configuration SFTP server

Add user group

groupadd sftp

Add users and set to SFTP group

sudo useradd -g sftp -s /sbin/nologin -M sftp

Modify the SFTP user’s password

sudo passwd sftp

***********

Create the root directory of the SFTP user and set the owner and group, modify the permissions (755)

cd /home
sudo mkdir sftp

sudo chown root:sftp sftp

sudo chmod 755 sftp

Create admin writable directory
in the directory of SFTP

cd sftp
sudo mkdir report

sudo chown admin:sftp report/

Modify the configuration file

sudo vim /etc/ssh/sshd_config

Modify the

#Subsystem      sftp    /usr/libexec/openssh/sftp-server
Subsystem       sftp    internal-sftp

Add at the end of the sshd_config file

Match User sftp
        X11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp
        ChrootDirectory /home/sftp

Restart the SSHD service

sudo service sshd restart

ftp client:

address : 192.168.1.10

user: sftp

password: xxxxxxx

protocol type : SSH2

port: 22

server folder: /home/sftp

pls use CuteFTP Pro® 8.3.3 or last version.

because CuteFTP Pro® 8.3.2 or earlier has no AES128 and AES256 ciphers.

will raise throw “SFTP21 error = #4” .

Unity “Feature `out variable declaration’ cannot be used because it is not part of the C# 4.0” error

Harry recently had a problem learning Unity.
After Unity2018 upgrades to 2019, all scripts will be unavailable, and the second half of the error report is “Feature ‘out variable declaration’ cannot be used because it is not part of the C# 4.0 language specification”.
After struggling for a long time, I finally found a solution.
As link: https://answers.unity.com/questions/1446008/assetsenemycs37-error-cs1644-feature-using-static.html
After this, select [Edit] — [Project Settings] — [Player] — [Other Settings] — [Configuration] under the Unity option select [.net 4.x Equivalent].