Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:08:04+00:00 2026-06-11T04:08:04+00:00

I am experimeting with web sockets. I look at http://www.websocket.org/echo.html site… They have simple

  • 0

I am experimeting with web sockets.

I look at http://www.websocket.org/echo.html site…
They have simple echo demo for client [ under Creating your own test ]
I copy that code…

<!DOCTYPE html>  
<meta charset="utf-8" /> 
<title>WebSocket Test</title>  
<script language="javascript" type="text/javascript">  

 var wsUri = "ws://echo.websocket.org/";
 var output;

 function init() 
 { 
  output = document.getElementById("output"); 
  testWebSocket(); 
 }

 function testWebSocket() 
 { 
  websocket = new WebSocket(wsUri); 
  websocket.onopen = function(evt) { onOpen(evt) }; 
  websocket.onclose = function(evt) { onClose(evt) }; 
  websocket.onmessage = function(evt) { onMessage(evt) }; 
  websocket.onerror = function(evt) { onError(evt) }; 
 }

 function onOpen(evt) 
 { 
     writeToScreen("CONNECTED"); 
     doSend("WebSocket rocks"); 
}

function onClose(evt) 
{ 
   writeToScreen("DISCONNECTED"); 
}
function onError(evt) 
{ 
    writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data); 
 }

 function doSend(message) 
 { 
      writeToScreen("SENT: " + message); 
      websocket.send(message); 
}

function writeToScreen(message) 
{ 
    var pre = document.createElement("p"); 
    pre.style.wordWrap = "break-word"; 
    pre.innerHTML = message; 
    output.appendChild(pre); 
}

window.addEventListener("load", init, false);

</script>  <h2>WebSocket Test</h2>  
<div id="output"></div> 

 </html>

It connects but can not able take response…

Should a client for websocket run under a websocket supported Server?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:08:05+00:00Added an answer on June 11, 2026 at 4:08 am

    you are missing a onMessage(evt) handler.

    function onMessage(message){
       writeToScreen("GOT MESSAGE: " + message.data); 
    }
    

    here is a working example.

    If you click the button it will open up a connection send a message and receives it back.

    Note that only your browser needs support!

    If you want to implement your own web-socket based service on a backend. You need a webserver that supports of cource..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web site that displays a table along with some buttons, navigation
I have been experimenting with a lot of web development apps like Drupal, Moodle,
I have recently started experimenting with Django for some web applications in my spare
I've been experimenting with OpenID, and have set up a sample web page to
I've been experimenting with making a simple Python web crawler, and I'm using regular
I have an ASP.NET MVC web app whose controllers use WCF to call into
I am experimenting with Java Web Start. I have just written a basic JApplet
I'm experimenting with web workers, and was wondering how well they would deal with
I have been experimenting with woopra.com A web analytics tool. Which requires a piece
I have been experimenting with WPF and rendering strict XAML markup in a web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.