WebSocket Framework Interview Questions
In this post we will look at WebSocket Interview questions. Examples are provided with explanation.
Q: What is WebSockets?
A: WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection.
Q: What are the disadvantages of using traditional HTTP request response communication model?
- Traditional HTTP requests are unidirectional - In traditional client server communication, the client always initiates the request.
- Half Duplex - User requests for a resource and the server then serves it to the client. The response is only sent after the request. So at a time only a single request occurs.
- Multiple TCP connections - For each request a new TCPsession is needed to be established and then closed after receiving the response. So without using WebSockets we will have multiple sessions.
- Heavy - Normal HTTP request and response require exchange of extra data between client and server.
Q: What are the advantages of using WebSockets over traditional HTTP communication?
- WebSocket are bi-directional - Using WebSocket either client or server can initiate sending a message.