Raspberry Pi - Web Server and APIWhy does a WebSocket connection on a Raspberry Pi remain open after the initial handshake, unlike HTTP?ABecause WebSocket uses a persistent TCP connection for continuous data exchangeBBecause WebSocket closes immediately after sending dataCBecause WebSocket uses UDP which is connectionlessDBecause WebSocket requires manual reconnection after each messageCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand WebSocket connection natureWebSocket upgrades HTTP to a persistent TCP connection for ongoing communication.Step 2: Compare with HTTP behaviorHTTP opens and closes connection per request; WebSocket keeps it open for live updates.Final Answer:Because WebSocket uses a persistent TCP connection for continuous data exchange -> Option AQuick Check:WebSocket connection = persistent TCP [OK]Quick Trick: WebSocket keeps TCP connection open for live data [OK]Common Mistakes:MISTAKESThinking WebSocket closes after each messageConfusing WebSocket with UDP protocolAssuming manual reconnection needed after every message
Master "Web Server and API" in Raspberry Pi9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Raspberry Pi Quizzes Automation and Scheduling - Home automation with relay modules - Quiz 7medium Automation and Scheduling - systemd service for auto-start - Quiz 2easy MQTT for IoT - paho-mqtt library usage - Quiz 5medium MQTT for IoT - paho-mqtt library usage - Quiz 8hard Security and Deployment - Headless deployment setup - Quiz 2easy Security and Deployment - Securing Raspberry Pi (SSH keys, firewall) - Quiz 9hard Security and Deployment - User authentication basics - Quiz 6medium Security and Deployment - Headless deployment setup - Quiz 4medium Web Server and API - Why web servers enable remote IoT control - Quiz 12easy Web Server and API - Flask web server on Raspberry Pi - Quiz 3easy