socket.io - encrytpting comunication between server and client - javascript

Hello everytone,
I have created a simple socket.io server that sends messages to a web application, once the application receives anything, it responds back to the server with another message..
And I suppose that all the communication between them is unencrypted. Now the question is, what's the best way to make the communication encrypted?
Is there any module for this?
Thanks in advance,
Alex

Just use wss:// as protocol instead of ws:// in the JavaScript. Then (if your server supports it) you connection will be secure.
Sadly i can't add any details, cause i dont know what server you are using..

Related

Sending data from rails to Websocket server?

I have used web-sockets on the client side but I am confused on how to build and communicate with web-socket server.
My application is in rails,from what I understood I need a separate web-socket server(preferably node).
I know how the communication happens from client to web-socket server but want to understand how will the communication from rails to node websocket server will happen?
My use case is like this -> any database operation -> inform to websocket-server-> inform to client
I can approach via hosted api's like pusher.js but want to approach of my own
Would request your help, if you think I am not approaching the right way?

Socket.io - Socket connection between clients

Im looking form something to make socket connection between client, without pass through the server. Is there any node package to do this?. Server only send the other client socket, and the clients recieve and send data to each other..
Or, how can we make the implamantation. We need to make a server in client side, but we dont have node installed in the client..
The closest thing that currently exists in some form is not currently part of socket.io. It is called WebRTC and is implemented in Chrome currently. It allows the browser to connect with other browsers.
http://www.webrtc.org
The question is what kind of application is your client? If you are talking about ordinary webbrowsers you need to think about writing pluings (tough case).
If you are talking about clients you have more control then you should look at technique Puching the hole exploited by Skype or P2P apps.
http://it.slashdot.org/story/06/12/15/191205/how-skype-punches-holes-in-firewalls
In general the server is used for TCP sockets orchestration the acutall comunication go directly.

Node server and WS server running side by side?

I'm really new to Node.js and have been wondering something. I'm trying to build a simple chat room application as a way of teaching myself how this all works.
The way I see it working is that I have a Node http server which serves the pages of my site (homepage, login, chat screen etc) and then I have a WS server which accepts short messages to relay to all connected users.
The thing is I can't work out if this is the correct way to approach this. Is it possible to authenticate users on the Node server and know that they have been authenticated on the WS server? Can they share some kind of session?
Any help is appeciated!
You don't mention what you're using to implement a WebSocket server, so I'll assume you're using socket.io. (If you're not, you should.)
You can use the socket.io handshake process to access the HTTP session state.
If you're using Express (once again, highly recommended), it's easy to tie the two together.

Javascript remote events?

Is it possible to have a web service notify web clients when something occurs via HTTP request/response? Right now my client has to poll the server using HTTP Requests at an interval to check for updates, but it would be far more convenient if I could register a javascript function to the server from my client and have it be simply called when server state changes.
Note that the web service is written in Python and utilizes HTTP APIs (I think it uses cherrypy, if that's relevant).
If this is possible could someone point me to some tutorial that explains how to do this or give me a basic understanding of how this can be accomplished?
Look into Comet
You can't start a request from the server to the client. You can only poll the server (which you did), use a hidden iframe, use a plugin, or use the new HTML5 WebSockets which allows the server to send a message to the client.
If you are into Node.JS, look into socket.io and hook.io
https://github.com/hookio
https://socket.io

callback javascript

I write a browser game (php, javascript) and I do not know how to make a callback. necessary that the server itself
found a client and call the function (only had one)
Don't write a browsergame if you don't know the basics! Browsergames are way too complex to learn programming.
If you want to make the server notify a client about something you will need to keep a connection open (search keywords: COMET, long polling) as you cannot initiate connections from the server to clients.
For this I can suggest you using Firebase. It is a API that let you to add cloud Data management that your user clients do. You can use that communication to search for client.
If I understand your question, what you need is a socket. Since you're using PHP and Javascript, a WebSocket might be just what you're looking for. With WebSockets, the connection between the client and the server is persisted, so the server can just push data/messages to any or all of the clients connected to it at any point in time. Likewise, the any client connected to the server can push messages/data up to the server.
Here's a video that describes how it works a bit https://www.youtube.com/watch?v=oJxWhmt5m-o

Categories

Resources