I was looking into Faye and socket-IO, socket-IO degrades to websockets, flash sockets, JSONP and such, but what are all the supported transport methods faye supports? Does it support flashsockets? Also does it support Multi-channels?
protocols folder on github
Websocket, xhr, JSONP.
It also has CORS which seems to be something to do with Cross origin resource sharing
No sign of flash sockets so far.
Faye uses WebSocket, XMLHttpRequest, CORS and JSON-P in order of preference. Each client can subscribe to as many channels as you like.
Related
i want to developp a messenger web app in realtime with nodejs and i wanted to know what's the best choice between websocket and socket.io for the server and the client side.my concerning is performance, like if i use websocket in both server and client side or socket.io what would be more performant. THX
THX.
socket.io was built on top of WebSocket. So there is no chance for it to be any faster than WebSocket. I think the role of socket.io to WebSocket is quite similar to the role of jQuery to Javascript. socket.io has fallback solutions when WebSocket is not available. So basically, it supports more browsers. I personally prefer to use WebSocket over socket.io. It's not because of performance advantage, it's actually about having more controls over the application architecture.
Don't compare Websockets over socket.io, Websocket is a protocol while socket.io is a socket framework (javascript) that uses Websocket as one of it's protocol. Socket.io (client) will use Websocket in communicating whenever it's supported, as a fallback, it will use the old-fashioned polling method when Websocket is not supported by the clients device.
I am trying to implement user authentication in an application that primarily uses WebSockets, but I am unsure how to begin.
I am using the Gorilla mux and websocket packages.
I have thought about using the method described here (files main.go and auth.go), but does this approach secure against authenticated users somehow hijacking each others sockets like described in this article?
Can someone suggest a good method or package(s) in Go?
Authenticate as you would for a plain HTTP request before upgrading the connection to the WebSocket protocol. Use whatever methods or packages you would use for plain HTTP requests.
A WebSocket connection can be hijacked to the extent that a plain HTTP connection can be hijacked. The WebSocket protocol does not introduce any new issues here.
Socket.io is a layer above WebSockets, long-polling and other techniques for sending events from the server to a browser client. Issues with Socket.io do not necessarily apply to direct use of a WebSocket.
As their faq states, socket.io supports cross-domain connections on every browser.
Could someone tell me, if cross-domain-communications then uses a particular transport mechanism like long-polling, or does it work with all supported mechanisms.
Annother thing is var socket = io.connect('http://localhost');. This is used the client to connect to the socket.io server. As this establishes a connection by WebSockets, longpolling, etc.. the above connect method itself uses a regular http request. Would not at least this request violate the same origin policy?
I just tested it in IE 8 and FireFox 14:
Cross-domain works for
jsonp
xhr-polling
Websocket
flashsocket
Cross-domain does not work for
htmlfile
htmlfile btw in general only works in IE, whereas websocket does not work in IE (< 10). flashsocket does not work in browsers that support websocket, which is why I tested that one in IE8 only.
Faye supports cross-domain subscription. Here is an excerpt from their docs:
Cross-domain operation
Faye clients and servers transparently support
cross-domain communication, so your client can connect
to a server on any domain you like without further configuration.
Anyone knows how it achieves it?
Faye uses JSONP to send a handshake request to the server when it's cross-domain, as the author of Faye explains in his reply here. It then selects a new transport from a list, in order of preference: WebSocket, EventSource, XHR, CORS and JSON-P. Note that WebSockets, once established, can also work cross-domain as previously discussed here.
I have an existing websocket server which serves json over websockets for IM on some non-http/s port.
This works fine for browsers which support websocket protocol but leaves a lot of other browsers from using the feature.
I was reading up on socket.io and nodejs and was thinking of adding a proxy using socket.io and nodejs in front of the websocket server to handle all websocket requests. Since socket.io supports fallback using flash websockets or long polling, I was hoping that using socket.io on client side will allow support for all older browsers as well.
So, my questions are,
Is the above approach feasible?
How does the fallback to long polling have to be handled in nodejs? Is it handled automatically or needs to be implemented?
Any existing resources which might help me out.
Thanks
It can be made feasible. However I suggest using NodeJS and Socket.IO for both your non-http request and http request for browsers. NodeJS can handle them very easily.
Socket.IO handles fallback automatically.
A simple chat system example here for http.