Git Product home page Git Product logo

socket.io-client's People

Contributors

3rd-eden avatar alexlmeow avatar crickeys avatar danielbeardsley avatar darrachequesne avatar david-fong avatar defunctzombie avatar digawp avatar dvv avatar einaros avatar fat avatar felixge avatar holic avatar jdahlq avatar kevin-roark avatar masakij avatar michael-luo avatar mickl avatar mikelimantara avatar nkzawa avatar paladox avatar paradite avatar pedrorw avatar peterdavehello avatar rase- avatar rauchg avatar sfilatov avatar tootallnate avatar ycarmel avatar zweihan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

socket.io-client's Issues

ws socket doesn't reset connected stated after disconnect

hi, I am using socket.io on the client and node-socket.io server. transports: [websocket]

everything works fine, but when the socket disconnects on the client it's not possible to connect again.

socket.connect() returns an socket object, but no connection is made nor callbacks fired.

the socket.connected = true, after disconnect()

thx, dz

Error handler

Do you plan something like
socket.on('error', function(){} );

when server is unreachable (when it doesn't exist or network is disconnected).

Cross domain support

Transports should expose if they're cross-domain capable, and when io.Socket is initialized with a host different from document.domain, the domain check should be incorporated.

Implement client-side disconnection detection

We should fire the disconnect event and cancel all the (ongoing) requests to the server through:

  • A timeout based on when the heartbeat is expected (if the heartbeat interval is 10000ms, and a heartbeat is not received by 12000ms, fire disconnect)
  • A xhr POST call failing (for htmlfile, xhr-polling, multipart) or timing out
  • A timeout for the iframe POST for jsonp-polling
  • A timeout based on the polling interval (if it's every 20000ms, fire it at 22000)

These should cover two scenarios:

  • Server is down
  • Client internet connection is down

Doesn't work in Safari 4 or Firefox 3.6

Hey,

First off, I'm really excited about using this framework! I have it working perfectly on Chrome and there's so many possibilities.

But I'm kind of stumped here. How do I get it to work with Firefox and Safari? They are both using the Socket.prototype functionality (logging the javascript), how should I go about debugging this? What are some reasons why it might not be working? Here is the client-side code I'm basically using:

$(document).ready(function() {  
  // where ./javascripts/socket.io/ is the root
  // directory of the socket-io project I downloaded from github
  io.setPath('./javascripts/socket.io/');
  socket = new io.Socket(null, {port: 8080});
  socket.connect();
  socket.addEvent('message', function(data) {
    alert(data);
  }
  socket.send("Hello")
})

And then I copied the chat example from the socket.io-node project for the node.js server. Any thoughts how to get this working?

missing onopen event for WebSocket transport

Hi, i encountered a problem when trying to use the WebSocket transport. I noticed that the WebSocket connect seems to work fine to connect to my web app (built using Rack), but Socket.IO don't know if the connect call was successful or not.

I noticed that the onopen() event of the WebSocket object, is not connected to the _onConnect() callback in the transport object. I added that assignment, and is now working fine.

Perhaps this is a fix to this problem. Can't seem to find any other issue reported here on GitHub, encountering the same problem with the WebSocket transport.

Here's the commit object:
http://github.com/markjeee/Socket.IO/commit/b408584e854de903cd3dfa68f1e26501901fbdd4

If you think this is not a problem, please just disregard.

Many thanks!

Mark

responst.flush() in IE6

I've had issues with IE6 (without Flash)

/lib/socket.io/transports/htmlfile.js:24
self.response.flush();

TypeError: Object .a ServerResponse. has no method 'flush'

response.flush() is used 3x in htmlfile.js.
I used a

if ('flush' in this.response) this.response.flush();

To fix it but have no clue if that's the best way.

IE 6.0 fallback without Flash

i put this in a new issue.

on IE 6.0 happens no fallback if flash is not installed - can this be fixed?
socket.connect() returns true and there is nothing "wrong" with the connect - but nothing happens - there is not even a connection going in any way to the server...

thanks!

Not all transports seem to work...

For me, specifying this as transports seems to work in all browsers I tried:
['websocket', 'flashsocket', 'xhr-polling']
htmlfile didn't seem to work for me in IE8... xhr-multipart I'm not sure about, maybe test some more.

XHR-polling in IE8 goes in loop

IE8 continues to connect multiple times with XHR-polling, goes in loop and therefore hangs the browser.
Dev. console shows that in onreadystatechange event,
the self._xhr.status has value "Unspecified error."

On the server side, the log is full of connects and disconnects.

WebSocket error on Firefox 3.6.10 beta

This is how I'm loading socket.io

<script src="js/Socket.IO/socket.io.js" type="text/javascript" language="javascript" charset="utf-8" />
<script type="text/javascript" language="javascript" charset="utf-8">
  io.setPath('js/Socket.IO/');
</script>

And here is the error I'm getting on firefox, as I assume normal websockets don't work yet and it's using the flash fallback:

[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf

I have tried manually setting the websocket location using

window.WEB_SOCKET_SWF_LOCATION = 'js/Socket.IO/lib/vendor/web-socket-js/';

To no avail. Any ideas?

Websockets are wonky in chrome 5.0.375.126

I'm using the example chat app, with an added line:
setInterval(function(){ console.log(socket.connected); }, 100);

The behavior I'm seeing is as follows:

  • The first window to visit the app doesn't connect.
  • The second window also doesn't connect.
  • When I refresh either, it also refuses to connect, but the other suddenly connects and receives data.

Any hints as to what's going on here?

BUG: XHR-Multipart / Polling without Flash in Firefox 3

Attempting to run Firefox 3 without flash, using either of these two sockets, causes an error (Specifically, this._xhr.send(); in each of them is considered to be missing an argument)

I have noted that in 3.6, without flash, these plugins work.

flashsocket doesn't work on firefox 3.68 (ubuntu 10.04)

hi, flashsocket transport doesnt work on my firefox.

When I load WebSocketMain.swf (I tried it also with WebSocketMainInsecure.swf) I get the following error from flash:
Verify Error: Error #1033: Cpool entry 42 is wrong type

then after clicking at continue:
Reference Error: Error #1065: Variable WebSocketMain is not defined

Firebug doesn't return any errors.

thanks! best, danielzzz

Queued messages encoded in different way to non-queued messages

There seems to be a problem with the way queued messages are sent (i.e. messages that are added to a queue because they are "sent" before the connection is established), at least over the WebSocket protocol.

I have some client-side code that looks like:

  websocket = new io.Socket('localhost');
  websocket.connect();

  websocket.send(JSON.stringify({"first": 1}));
  websocket.send(JSON.stringify({"first": 1}));
  websocket.send(JSON.stringify({"first": 1}));

  setTimeout(function() { 
      websocket.send(JSON.stringify({"second": 2})); 
      websocket.send(JSON.stringify({"second": 2})); 
      websocket.send(JSON.stringify({"second": 2})); 
  }, 2000);

If I dump the raw messages, as they appear on the server with some code like

client.on('message', function(message){
    sys.puts(sys.inspect(message));
});

then I get the output

'["{\\"first\\":1}","{\\"first\\":1}","{\\"first\\":1}"]'
'{"second":2}'
'{"second":2}'
'{"second":2}'

I made a patch to fix this, which results in the second style always being received by the server, for both queued and non-queued messages:

diff --git a/lib/socket.js b/lib/socket.js
index 3066872..3687eaf 100644
--- a/lib/socket.js
+++ b/lib/socket.js
@@ -95,7 +95,9 @@

        Socket.prototype._doQueue = function(){
                if (!('_queueStack' in this) || !this._queueStack.length) return this;
-               this.transport.send(JSON.stringify([].concat(this._queueStack)));
+               for (var i = 0; i < this._queueStack.length; i++) {
+                       this.transport.send(this._queueStack[i]);
+               }
                this._queueStack = [];
                return this;
        };

(I think these will probably also be in the pull queue.)

Add option for alternative flash services port

This is more of a feature request than an issue, but I don't run my node apps as root, and 843 is one of the privileged ports. I manually patch socket.io to change the port. (I have a iptables rule to NAT 843 to the higher port).

It would be cool if this were an option so I don't have to apply a patch to ever release of socket.io.

Thanks.

Weird error with socketio

I consistently get the error below when I run the server (test/server.js):

Error: Must have start <= end
at Stream.ondata (http:526:27)
at IOWatcher.callback (net:307:31)
at node.js:748:9

This kills the server too... any idea why?

XHR-Multipart fails to send messages in high latency environments

I've tested this in Firefox 3.6 using Charles Proxy set to 250ms and 400ms. I have an app where I send messages to the server and wait for a response. In high latency environments, I've seen that some messages never make it to the server when I do many actions very quickly (I only ever send one message at a time - so it's not a problem of sending many messages concurrently as each subsequent message waits for the ack from the previous message). I've pasted a sample run of the app from firebug - the random string of characters are unique identifiers on the messages: http://gist.github.com/592812

On the server side, I'm printing the message id on client.on('message') and all that is output is:
qjDG0g

Will try to dig more into this soon, but just wanted to post this here in case anyone had any ideas.

Unwanted disconnection with xhr-polling

When the xhr-polling transport is used (tested from an iPhone and an iPad), sending data from the client to the server at the wrong time causes a spurious disconnection.

To reproduce, just add such a snippet to the chat.html example:

  socket.on('connect', function() {
      send();
  });

On the data has been sent, the connection breaks after a few seconds:

27 Aug 00:25:32 - Initializing client with transport "xhr-polling"
27 Aug 00:25:32 - Client 7475254631135613 connected
27 Aug 00:25:43 - Client 7475254631135613 disconnected
27 Aug 00:25:53 - Couldnt find client with session id "7475254631135613"
27 Aug 00:25:53 - Couldnt find client with session id "7475254631135613"
27 Aug 00:25:53 - Couldnt find client with session id "7475254631135613"

Error in clone code

I tried to use your transportOptions, but it didn't work because of an error here:

@@ -46,7 +46,7 @@ io.util = {};
                                return clone;
                        } else if (typeof item == 'object') {
                                clone = {};
-                               for (var key in object) clone[key] = object.clone(object[key]);
+                               for (var key in item) clone[key] = object.clone(item[key]);
                                return clone;
                        } else {
                                return item;

XHR _onClose() missing

XHR "disconnect" method tries to call a none-existent _onClose() implementation, which is required to actually close the connection.

Document what files are absolutely necessary

I'm bundling Socket.IO in a project of mine but don't want to have to bundle all of it (don't want to burden my users), I only want to bundle the files that are absolutely necessary. Is there anyway we can get a list of exactly what files Socket.IO needs publicly available to clients?

Like is it just socket.io.js and the web-socket-js flash file?

Allow multiple listeners to be bound to a server

I've have two distinct types of connections coming at my server - it would seem the easiest way to separate them would be to bind create two io.listeners and change the resource of each connection type - however in the current implementation in Listener.init will just grab the last Listener bound to the server!

p.s Fantastic piece of software!

Safari 4 on iOS 4.1 - Debug console Javascript error

I keep getting this Javascript error on the Safari 4 debug console (iOS 4.1):

"Javascript Error on Line 1550

http:///www.mydomain.com/Socket.IO/socket.io.js

Flash player is not installed"

Is there any way to suppress this error in future releases of Socket.IO?

I realise that neither Flash nor WebSockets are supported on Safari iOS at the moment. I should add that XHR long polling works just fine!

Great project by the way!

Downloads package doesn't include SWF file

I think this is just a packaging issue but the downloads for the client do not include the required SWF file in the lib/vendor/web-socket-js folder (the folder is completely empty).

I was able to find the SWF and the example chat files from that folder in the github source however but they probably need to be added to the download zip.

Opera jsonp-polling fix for Opera

line 79 (or approximately) in jsonp-polling.js client side,
if (this._iframe.attachEvent){
should be changed to
if (!window.opera && this._iframe.attachEvent){
or complete will never trigger in opera so only first send will work.

send message in seperate lines

Why did I get seperate message on server side when I use socket.send('ok test')?

Here's the response on server side with sys.log(message);
17 May 03:06:56 - Initializing client with transport "websocket"
17 May 03:06:56 - Client 5388960442505777 connected
17 May 03:06:56 - [
17 May 03:06:56 - "
17 May 03:06:56 - o
17 May 03:06:56 - k
17 May 03:06:56 -
17 May 03:06:56 - t
17 May 03:06:56 - e
17 May 03:06:56 - s
17 May 03:06:56 - t
17 May 03:06:56 - "
17 May 03:06:56 - ]

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.