QuizzesWebSockets — Real-Time, Two-Way Connections — Concept Check
intermediate
fastapi

WebSockets — Real-Time, Two-Way Connections — Concept Check

Questions on WebSockets — Real-Time, Two-Way Connections. A @app.websocket endpoint accepts a persistent two-way connection: await receive/send in a loop, a ConnectionManager broadcasts to rooms, auth happens at the handshake, and multi-instance fan-out needs Redis pub/sub.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on WebSockets — Real-Time, Two-Way Connections — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer is implementing a chat application using WebSockets and notices that messages are not being broadcasted to all participants in a room. What could be the issue?

    • AThe WebSocket connection is not persistent.
    • BThe ConnectionManager is not correctly tracking room members.
    • CThe WebSocket handshake is not completed.
    • DThe server is using HTTP instead of WebSockets.
  2. 2.During a WebSocket connection, a developer wants to authenticate users. Which method should they use to pass the token?

    • ASend the token in a separate HTTP request before the WebSocket connection.
    • BEmbed the token in the WebSocket URL path.
    • CUse the Authorization header during the WebSocket handshake.
    • DInclude the token in the WebSocket URL as a query parameter.
  3. 3.A WebSocket server is deployed across multiple pods, but messages are not reaching all clients. What is a likely cause?

    • AThe server is not using FastAPI.
    • BRedis pub/sub is not being used for cross-pod communication.
    • CThe WebSocket connections are not persistent.
    • DThe WebSocket handshake is failing.
  4. 4.A developer observes that after a WebSocket client disconnects, messages are still being sent to the client. What might be the problem?

    • AThe WebSocket handshake was incomplete.
    • BThe ConnectionManager is not cleaning up disconnected sockets.
    • CThe server is not using a ConnectionManager.
    • DThe WebSocket connection was not properly closed.
  5. 5.A WebSocket server using FastAPI is experiencing frequent disconnections. What could be a potential solution?

    • ASwitch to using HTTP for connections.
    • BDisable the ConnectionManager.
    • CUse longer-lived tokens for authentication.
    • DIncrease the proxy_read_timeout setting in the load balancer.
  6. 6.What is the role of the ConnectionManager in a WebSocket application?

    • AIt manages HTTP requests and responses.
    • BIt handles WebSocket authentication.
    • CIt tracks active WebSocket connections and handles broadcasting.
    • DIt upgrades HTTP requests to WebSocket connections.
  7. 7.A developer wants to ensure messages are delivered to all clients in a multi-instance WebSocket setup. Which technology should they use?

    • AWebSocket handshake optimization.
    • BDirect socket communication between instances.
    • CHTTP polling for message delivery.
    • DRedis pub/sub for message distribution.