×

WebSockets Interview Questions

1) What is Web Sockets?

Web Sockets is a two way communication between the clients and the servers. Here, the clients and servers both the parties can communicate and exchange data at the same time.

2) What are the features of Web Sockets?

Features of Web Sockets are:
  • Web sockets are transforming to cross platform standard.
  • It provides a two-way communication over single TCP connection.
  • With the help of protocols, the real time communication between web servers and clients is possible.

3) What are the various techniques used for duplex communication between the server and the client?

Techniques used for duplex communication are:
  • HTML5
  • Polling
  • Streaming
  • Long Polling
  • Postback and AJAX

4) What are the main Web Socket API events?

Four main Web Socket API events are:
  • Open
  • Close
  • Error
  • Message

5) How to create a Web Socket connection?

By using the following code:
  1. var socket = new WebSocket('ws://echo.websocket.org');

6) What is onLoad in Web Sockets?

It is an event of Web socket which helps in creation of object of JavaScript and initialization of connection.

7) What is onOpen in Web Sockets?

It is an event of Web Socket which is used to establish a connection with the server and also sends the status of the connection.

8) What is close() method in Web Sockets?

close() method stands for goodbye handshake. The close() method is used to terminates the connection and no data can be exchanged unless the connection opens again.

9) How to create a Web Socket instance in server?

By using the following code:
  1. var server = new WebSocketServer("ws://localhost:8181");

10) What is Send() Method?

Send() Method: It is used to transmits the desired message to the specified client. It is also used to store the text or binary data across the clients.

11) What are the advantages of Web Sockets?

Advantages of Web Sockets are:
  • Full Duplex
  • Bidirectional
  • Single TCP Connection
  • User-friendly API

12) What is XSS in Web Sockets?

XSS stands for Cross-site scripting. It is a vulnerability that enables attackers to inject client-side scripts into web pages.

13) Which method is used to close the Web Socket?

Socket.close() method is used to close the Web Socket.

14) How do the client and the server communicate the following rules defined by the Web Socket protocol?

The client and the server communicate over a Long-lived TCP Socket.

15) How can we check the subprotocol being used by the client?

By checking the protocol property of the socket.

16) Which event is fired when something wrong occurs between the communications in Web Sockets?

onerror event is fired.

17) What is JSON in Web Sockets?

JSON: stands for JavaScript Object Notation. It is a lightweight data-interchange format for transferring human-readable data between the computers.

18) What is RFC 6455?

RFC 6455: It is the latest specification of Web Socket protocol. It is supported by various browsers like Internet Explorer, Google Chrome, Mozilla Firefox and Opera.

19) What are the major drawbacks of AJAX in comparison with Web Sockets?

The major drawbacks of AJAX in comparison with Web Sockets are:
  • Web Server consumes more resources.
  • Communication is half-duplex.
  • In Web Sockets, AJAX send HTTP header which makes total size larger.

20) What is Polling in Web Sockets?

Polling: It is a method or technique which is used for duplex communication between the server and the client. It performs periodic requests regardless of the data that exists in the transmission. Here, periodic requests are sent in a synchronous way.

21) What is Long Polling in WebSockets?

Long Polling: It includes similar technique like polling. The client and the server keep the connection active until some data is fetched or timeout occurs. Long polling is performance improvement over polling process.

22) What are the two main actions that are supported by Web Socket protocol?

The two main actions that are supported by Web Socket protocol are:
  • send( )
  • close( )

23) What is API in Web Sockets?

API: stands for Application Program Interface. API is a set of protocols and routines for building software applications.

24) What are the features of API (Application Program Interface)?

The features of API are:
  • Application Program Interface makes it easier to develop a program by providing all the building blocks.
  • It specifies how software components should interact and APIs should be used with graphical user interface (GUI) components.
  • REST avoids ambiguity.
  • Flexibility is provided by assigning resources (Universal Resource Identifiers).

25) Why REST avoids ambiguity in Web Sockets?

REST avoids ambiguity because each term in REST has a specific meaning (GET, POST, PUT and DELETE).

Related Topics

WebSockets Interview Questions

1) What is Web Sockets? Web Sockets is a two way communication between the clients and the servers. Here, the clients and servers both the parties can communicate and exchange data...

3 minutes read.

Top 15 Framework7 Interview Questions for 2024

1) What is Framework7? Framework7 is an open source mobile HTML framework. It is used todevelop hybrid mobile apps for iOS and Android devices. 2) Why, framework7 is popular? There are various reasons...

8 minutes read.

Top 22 DOJO Interview Questions for 2024

1) What is DOJO? DOJO is an open source JavaScript framework designed for very fast development of JavaScript/AJAX based application and websites having cross platform interdependencies. 2) Enlist all features of DOJO. ...

4 minutes read.

Top 18 Blockchain Interview Questions and Answers for 2024

Top 20 Commonly Asked Blockchain Interview Questions and Answers 1. What do you understand by Blockchain? Blockchain is a chain of blocks made up of digital pieces of information or can be defined as...

6 minutes read.

Top 50 ReactJS Interview Questions for 2024

Top 50 Frequently asked ReactJS Interview Questions Q-1. What is React? Ans-1 React is a front-end JavaScript library which is developed by Facebook in 2011. It follows the component-based approach and allows us to...

15 minutes read.

Top 15 Servlet Interview Questions for 2024

1) What is Servlet? It is a technology used to create web applications. It is a web component which is used to create dynamic web pages. It consists of many interfaces and classess...

2 minutes read.

Top 30 SQLite Interview Question for 2024

1) What is SQLite? It is an in-process library which implements self-contained, serverless, zero-configuration, transactional SQL database. 2) What datatype does SQLite supports? It uses dynamic typing and data can be stored in...

5 minutes read.

Top 30 SQL Interview Questions for 2024

1. What is SQL? Ans. SQL stands for Structured Query Language.  It is a standard computer language for accessing, storing, and manipulating data stored in the relational database. SQL become an International Standard Organization (ISO)...

11 minutes read.

Top 15 PouchDB Interview Questions for 2024

1) What is PouchDB? PouchDB is an in-browser database that allows applications to save data. It is an open source database. It runs in Node.js. 2) In which language PouchDB was written? PouchDB was written in JavaScript language. 3)...

2 minutes read.

Top 28 Scala Interview Questions for 2024

1) What is Scala? Scala is a functional and object-oriented programming language. It is used to develop web application, mobile application, enterprise application, desktop based application etc. Everything in Scala is in object...

4 minutes read.

Flutter Interview Questions

Here’s a list of top Flutter questions that are frequently asked. Q1.  Is Flutter an open-source? A1.  Yes, Flutter is a 100% open-source software development kit. Q2.  What are flutter widgets? A2.  Widgets are...

7 minutes read.

Top 30 Flex Interview Questions for 2024

1) What is Flex? Flex is an open source framework which is used to build applications for mobile, browser and desktop. It provides FLEX SDK consisting of the Flex class library, Flex...

4 minutes read.

Top 30 AngularJS Interview Questions and Answers for 2024

Most Frequently asked AngularJS Interview Questions and Answers for Fresher 1) Describe Angular JS ? It is a powerful framework of JavaScript. AngularJS is used to design Rich Internet Application. This framework...

5 minutes read.

Top 19 Google Maps Interview Questions for 2024

1) What is Google Maps? Google Maps is a web-based service developed by Google. It contains geographical information and provides routes and information to the client. 2) What are the features provided...

5 minutes read.

Top 15 Xamarin Interview Questions for 2024

1) What is Xamarin? Xamarin is a .NET framework. It allows to create an application that run on multiple platforms. Xamarin Tutorial uses C# language and .NET framework to deliver native...

2 minutes read.

Top 10 Java Swing Interview Questions for 2024

1) What is Java Swing? It is a part of JFC (Java Foundation Classess) that is used to create window-based applications. Java Swing components are platform independent and lightweight . 2) What is...

3 minutes read.

Top 15 Highcharts Interview Questions for 2024

1) What is Highcharts? Highcharts is a JavaScript based charting library. It is used to enhance web applications by adding interactive charting capability. Highcharts supports a wide range of charts. Charts are drawn using...

2 minutes read.

Top 15 PhantomJS Interview Question for 2024

1) What is PhantomJS? PhantomJS is a lightweight headless scripted browser built on WebKit. It is used for automation web page interaction. 2) Why it is called as headless browser? PhantomJS called as...

4 minutes read.

Top 48 C# Interview Questions for 2024

1) Write a program in C# to print "HELLO WORLD"? class Program         {          static void Main(string  args[])           {             System.Console.WriteLine(" HELLO WORLD ");             }          } 2) Write a program in C# to print "TutorialandExample" using namespace? Here, namespace is used to group related classes. Using System;    namespace  TutorialandExample      {         public class           {             public static void Main(string[]  args)             {              Console.WriteLine(" TutorialandExample ");             }          }       } 3) What are the...

8 minutes read.

Top 28 Prototype Interview Questions for 2024

1) What is Prototype? Prototype is a JavaScript framework which is used in dynamic web applications. It is a namespace and a module that is used to manage HTML forms. It is also...

4 minutes read.