Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect to websocket.org echo service #533

Closed
fajarmf opened this issue Sep 22, 2011 · 5 comments
Closed

Connect to websocket.org echo service #533

fajarmf opened this issue Sep 22, 2011 · 5 comments

Comments

@fajarmf
Copy link

fajarmf commented Sep 22, 2011

Hi,
I want to use socket io client that can work with the echo service of http://websocket.org/echo.html (ws://echo.websocket.org). However I tried creating the following code:

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect('ws://echo.websocket.org');
  console.log('done connect');
  socket.on('connect', function (data) {
    socket.send('hi from me');
  });
  console.log('done setup');
</script>

But I cannot seems to make it works, i.e. I didn't get the echo from the server.

Thanks in advance,

Idos

@TooTallNate
Copy link
Contributor

Well the socket.io client is expecting to connect to a socket.io server, so this just plain won't work...
Maybe try web-socket-js if you're looking for a plain 'ol WebSocket fallback...

@fajarmf
Copy link
Author

fajarmf commented Sep 22, 2011

Does it also mean that the socket-io server will not work with other websocket client?

@TooTallNate
Copy link
Contributor

A regular websocket client can connect to a socket.io server, but there will be socket.io's framing and heartbeats included; that's what the socket.io client abstracts away (for the websocket transport at least).

@fajarmf
Copy link
Author

fajarmf commented Sep 24, 2011

When you say a normal websocket client can connect to socket.io server. Should the xlient point to server with ws:// or http:// adress?

I am asking this because I have the client on android device, it works with websocket.org demo server. But it couldnt connect to my socket io swrver

@3rd-Eden
Copy link
Contributor

You need to the socket.io encoding to be able to communicate with the Socket.IO server. See github.com/learnboost/socket.io-spec for details about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants