Giter Club home page Giter Club logo

Comments (14)

eidheim avatar eidheim commented on May 19, 2024

You need to wait for the connection to establish, so instead of the line ws.send("test") do something like this:

ws.onopen=function(evt){
  ws.send("test");
}

from simple-websocket-server.

mkkhedawat avatar mkkhedawat commented on May 19, 2024

No, That is resolving only

Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.

That was understood.

But Handshake Error is still there

WebSocket connection to 'ws://localhost:8080/echo' failed: Connection closed before receiving a handshake response

from simple-websocket-server.

eidheim avatar eidheim commented on May 19, 2024

What browser do you use? This happens when you reload (and maybe leave) the page while having an open websocket connection. Just means that you have not closed it. To remove the message I guess you can do a ws.close() when the page unloads, but I do not know the JavaScript code for this.

from simple-websocket-server.

mkkhedawat avatar mkkhedawat commented on May 19, 2024

I am using chrome.
On Firefox it says

Firefox can't establish a connection to the server at ws://localhost:8080/echo.

I am not reloading or navigating away.
Web-socket connection is not being established I believe.
If it did , shouldn't I get trace in serve side ?

from simple-websocket-server.

eidheim avatar eidheim commented on May 19, 2024

Try this html file from a similar issue posted on this project:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WebSocket Test</title>
</head>
<body>
<script>
window.onload=function(){
  var ws=new WebSocket("ws://localhost:8080/echo");
  ws.onmessage=function(evt){console.log(evt.data);};
  ws.onopen=function(evt){
    ws.send("test");
    setTimeout(function(){ws.close();}, 1000);
  }
}
</script>
</body>
</html>

This one closes the connection after 1 sec, also the charset is set and its using the window.onload function. And yes you should see output on the terminal running ws_examples.

from simple-websocket-server.

mkkhedawat avatar mkkhedawat commented on May 19, 2024

Nah ! Same error. Is it still working at your system ? Please use the same steps as me.
If yes tell me the configs ?

from simple-websocket-server.

eidheim avatar eidheim commented on May 19, 2024

Yes this is working on Debian stable, testing and OS X. Do you get output when you start ./ws_examples?

from simple-websocket-server.

eidheim avatar eidheim commented on May 19, 2024

Also please try cmake .;make;make test and see if the tests are passed.

from simple-websocket-server.

eidheim avatar eidheim commented on May 19, 2024

You can also open the console in Chrome, and type in the JavaScript commands yourself:

var ws=new WebSocket("ws://localhost:8080/echo");
ws.onmessage=function(evt){console.log(evt.data);};
ws.send("test"); //try this line again if the connection is not up yet.

from simple-websocket-server.

mkkhedawat avatar mkkhedawat commented on May 19, 2024

I do not get anything on running ./ws_examples

When I do cmake, It ask for compiler 4.9.
I have 4.8.2 installed on Ubuntu 14. It was able to get compiled via traditional method.

from simple-websocket-server.

eidheim avatar eidheim commented on May 19, 2024

Strange you managed to compile it on g++ 4.8, I think regex was not supported before 4.9, and that is why you need g++ 4.9. I think it should be possible to install this on Ubuntu. Maybe do an upgrade on your system? g++ 4.9 is available in debian stable now, and should thus be installable on all its derivatives like Ubuntu (hopefully).

from simple-websocket-server.

ZX-Diablo avatar ZX-Diablo commented on May 19, 2024

I've made g++4.8 compilable fork but haven't updated code for a long time thou

from simple-websocket-server.

mkkhedawat avatar mkkhedawat commented on May 19, 2024

Okay , It seems the issue here then.

It was compiling with g++ 4.8.2 and running but not giving any traces.
But when compiled with 4.9 , it is running fine.

Thanks for your time.

Closing Issue :)

from simple-websocket-server.

taimur38 avatar taimur38 commented on May 19, 2024

I'm having this issue currently, and am running on windows.
Visual Studio 2015, I'm just pointing to Simple-WebSocket-Server in AdditionalIncludeDirectories.

Any ideas on how I can get around this? Looks like I might just need to update visual studio

from simple-websocket-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.