title: Websocket connection. Why are we making a call to ws://echo.websocket.org?
body: <p>I am writing some websocket code and I have this so far:</p>
  
  <pre><code>window.onload = function() {
  
    // Get references to elements on the page.
    var form = document.getElementById('message-form');
    var messageField = document.getElementById('message');
    var messagesList = document.getElementById('messages');
    var socketStatus = document.getElementById('status');
    var closeBtn = document.getElementById('close');
  
    var socket = new WebSocket('ws://echo.websocket.org');
  
    // Show a connected message when the WebSocket is opened.
    socket.onopen = function(event) {
      socketStatus.innerHTML = 'Connected to: ' + event.currentTarget.url;
      socketStatus.className = 'open';
    };
  
    // Handle any errors that occur.
    socket.onerror =  function(error) {
      console.log('WebSocket Error: ' + error);
    };
  
    form.onsubmit = function(e) {
      e.preventDefault();
  
      // Retrieve the message from the textarea.
      var message = messageField.value;
  
      // Send the message through the WebSocket.
      socket.send(message);
  
      // Add the message to the messages list.
      messagesList.innerHTML += '&lt;li class="sent"&gt;&lt;span&gt;Sent:&lt;/span&gt;' + message +
                                '&lt;/li&gt;';
  
      // Clear out the message field.
      messageField.value = '';
  
      return false;
    };
  
    socket.onmessage = function(event) {
      var message = event.data;
      messagesList.innerHTML += '&lt;li class="received"&gt;&lt;span&gt;Received:&lt;/span&gt;' +
                               message + '&lt;/li&gt;';
    };
  
    closeBtn.onclick = function(e) {
      e.preventDefault();
  
      // Close the WebSocket.
      socket.close();
  
      return false;
    };
  
    socket.onclose = function(event) {
      socketStatus.innerHTML = 'Disconnected from WebSocket.';
      socketStatus.className = 'closed';
    };
  };
  </code></pre>
  
  <p>What is this code doing: </p>
  
  <pre><code> var socket = new WebSocket('ws://echo.websocket.org');
  </code></pre>
  
  <p>What url is that? When I visit there with my browser it does not exist but it seems to be important as I can't simply jus replace that url with random strings. What does it do? Is Websocket an external API?</p>
  
  <p>I'm looking at the network tab and I see this:</p>
  
  <pre><code>Request URL: ws://echo.websocket.org/
  Request Method: GET
  Status Code: 101 Web Socket Protocol Handshake
  </code></pre>
  
  <p>conceptually, what is going on? Why do I need to make a request to an external site to use Websockets?</p>