Entradas

Mostrando entradas de octubre, 2022

12 React Websocket. Problems with useEffect with arrays and concatenated strings

Imagen
1. Explanation of this example In this example, the process is the following: the client (React) sends a request to the server. The server receives the request and while processing, it sends messages informing the client about the process The last message sent to the client is "close-me", which means that the server has finished its work When the client receives any message, this message is stored both in a string and in an array When the client receives the message "close-me", then it closes the connection. 2. Problems with variables 1. Inside the " useEffect ", the variables in an assignment must be all in " useState ." As inside a " useEffect " code, the variables that don't use " useState " are initialized. 2. Don't use " useEffect " for detecting changes in arrays or strings whose value is concatenated ( for instance setMyVar(myVar + aString) ) 3. Taking care of non-open connections If you want to send

11. Nginx and javascript module

1. Introduction While Nodejs admits some javascript coding, Nginx has a javascript module that enables giving more security and flexibility to this web server (diagnostic logging, response filtering, custom authentication schemes...) 2. Installation 2.1 Try this installation (in Linux Mint does not work for me) I have had problems installing Nginx javascript, so I had to reinstall Nginx using this site  and this one . #Install the prerequisites: sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring #Import an official nginx signing key so apt could verify the packages authenticity. Fetch the key: curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg > /dev/null #Verify that the downloaded file contains the proper key: gpg --dry-run --quiet --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg #The output should contain the full fingerp